transform_fold() does not work after renaming columns
See original GitHub issueRunning
d1_coll = alt.hconcat()
d1_bvb = bvb.copy()
d1_bvb.rename(columns = {'value' : 'value_renamed', 'fee' : 'fee_renamed'}, inplace=True)
for chart in [
[0 , 'All players'],
[1, 'Excluding free agents'],
[1000000, 'Transfers above €1 million']
]:
d1_chart = alt.Chart(
d1_bvb,
title = chart[1]
).transform_filter(
datum.fee >= chart[0]
).transform_fold(
['value_renamed', 'fee_renamed'], as_ = ['key_fold', 'value_fold']
).mark_bar(
clip=True
).encode(
y=alt.Y('mean(value_fold):Q', scale=alt.Scale(domain=(0,14000000)), title='Average in (€)'),
x=alt.X('key_fold:N', title = 'x-Axis title'),
color=alt.Color('key_fold:N'),
column=alt.Column('trans_type', title='column title', spacing=5)
)
d1_coll |= d1_chart
d1_coll
returns no chart.
When I comment out the d1_bvb.rename()
line and change the first argument in transform_fold()
to value
and fee
, it returns the correct chart.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Renaming the column names of pandas dataframe is not ...
I am trying to rename the column names but it not working as expected. Code: mapping = {df.columns[0]:'Date', df.columns[1]: ...
Read more >Renaming columns -> new name not showing for site members
Hi community, I noticed that in a recent created SharePoint Online site, that when I rename columns, I (as creator) see the new...
Read more >Renaming a field in the dataset - AWS Glue Studio
You can use the RenameField transform to change the name for an individual property key in the dataset.
Read more >pandas.DataFrame.rename — pandas 1.5.2 documentation
If 'raise', raise a KeyError when a dict-like mapper , index , or columns contains labels that are not present in the Index...
Read more >R dplyr & plyr Error: Can't rename columns that don't exist. (2 ...
Let's start right away. Creation of Example Data. We'll use the following data as basement for this R programming tutorial: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The only way to change the names of your columns once they’re passed to the chart is to use a calculate transform. You could do something like this:
Thank you!