FutureWarning: using a dict on a Series for aggregation is deprecated and will be removed
In the process of learning Pandas, I encountered the following warning. Although it is not an error, it is uncomfortable to see this kind of warning.
This is the code I wrote
#打印出每个大陆对spirit饮品消耗的平均值,最大值和最小值
spirit = drinks.groupby('continent')['spirit_servings'].agg({"spirit_avg":'mean','spirit_max':'max','spirit_min':'min'})
Then the following warning appears when running
The error roughly means: Future Warning: Aggregation using dict over sequences is deprecated and will be removed in a future release
That is to say, this syntax format will be deprecated in the future. It is used now as a prompt. In order to ignore this warning, we can use the following two lines of code to solve the problem.
import warnings
warnings.filterwarnings("ignore")
then run again