Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 16420

Rename result columns from Pandas aggregation ("FutureWarning: using a dict with renaming is deprecated")

$
0
0

I'm trying to do some aggregations on a pandas data frame. Here is a sample code:

import pandas as pddf = pd.DataFrame({"User": ["user1", "user2", "user2", "user3", "user2", "user1"],"Amount": [10.0, 5.0, 8.0, 10.5, 7.5, 8.0]})df.groupby(["User"]).agg({"Amount": {"Sum": "sum", "Count": "count"}})Out[1]:       Amount               Sum CountUser              user1   18.0     2user2   20.5     3user3   10.5     1

Which generates the following warning:

FutureWarning: using a dict with renaming is deprecated and will be removed in a future version return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)

How can I avoid this?


Viewing all articles
Browse latest Browse all 16420

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>