Is it possible to rename systematically output column from agg
?
#2204
-
Hi, As per documentation df_pets.groupby(by='animal').agg({'age': 'mean',
'cuteness': ['mean', 'std']})
# animal age cuteness_mean cuteness_std
0 dog 3.33333 9 0.816497
1 cat 5 5 0
2 guinea pig 2 6 2 Please, can we enforce this renaming systematically? Or should I explicitly ask for renaming the output column, as described in the documentation as well. df_pets.groupby(by='animal',
agg={'mean_age': vaex.agg.mean('age'),
'cuteness_unique_values': vaex.agg.nunique('cuteness'),
'cuteness_unique_min': vaex.agg.min('cuteness')})
# animal mean_age cuteness_unique_values cuteness_unique_min
0 dog 3.33333 3 8
1 cat 5 1 5
2 guinea pig 2 2 4 For this latter case, if I have to retain it, could we have a way, quite similar to pandas, to use function name (as string) instead of the function themselves? Thanks for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I am quite happy with the way it is at the moment. With that said, I don't mind the proposal (the first code block). I would live this one up to @maartenbreddels. |
Beta Was this translation helpful? Give feedback.
I am quite happy with the way it is at the moment. With that said, I don't mind the proposal (the first code block).
I would be weary of adding yet another API tho.. And in case of the pandas thing, that is a shortcut for
pd.NamedAgg
which i prefer to use in most serious cases.I would live this one up to @maartenbreddels.