日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

pandas.core.base.SpecificationError: nested renamer is not supported解决方案

發(fā)布時間:2023/12/29 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pandas.core.base.SpecificationError: nested renamer is not supported解决方案 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

利用pandas dataframe的groupby和agg方法寫詞頻統(tǒng)計代碼的時候,遇到的pandas版本迭代造成的原有代碼不可使用的情況。

遇到錯誤

pandas.core.base.SpecificationError: nested renamer is not supported

問題代碼塊

words_stst = word_df.groupby(by='segment')['segment'].agg({'計數(shù)':'size'}) words_stst = words_stst.reset_index().sort_values(by=['計數(shù)'],ascending=False)

解決方法

words_stst = word_df.groupby('segment').agg(計數(shù)=pd.NamedAgg(column='segment', aggfunc='size')).reset_index().sort_values(by='計數(shù)', ascending=False)

pandas版本迭代的文檔鏈接

https://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.25.0.html

原文鏈接

https://blog.csdn.net/qq_29815255/article/details/107053035

總結

以上是生活随笔為你收集整理的pandas.core.base.SpecificationError: nested renamer is not supported解决方案的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。