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

Copyright statement: Original by the author, please attach the article link for reprinting. https://blog.csdn.net/qq_36330643/article/details/81329204

In python's pandas, when statistical aggregation, there is a version problem, indicating that the dictionary format is not supported.

For example, the following code can be changed like this.

    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 = ['计数']  

Related Posts