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

版权声明:作者原创,转载请附上文章链接。 https://blog.csdn.net/qq_36330643/article/details/81329204

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

猜你喜欢

转载自blog.csdn.net/qq_36330643/article/details/81329204
今日推荐