1. 程式人生 > >using a dict on a Series for aggregation is deprecated and will be removed in a future version

using a dict on a Series for aggregation is deprecated and will be removed in a future version

python的pandas中,在統計聚合的時候,版本問題,提示不支援字典格式了。

比如,下面程式碼這樣改就可以了。

    words_stat = words_df.groupby(by=['segment'])['segment'].agg({"計數": numpy.size})  
    上面程式碼改成下面程式碼就可以了。應該是版本問題。  
    word_stat = word_df.groupby(by=['segment'])['segment'].agg(np.size)  
    word_stat = word_stat.to_frame()  
    word_stat.columns = ['計數']