pandas.core.base.SpecificationError: nested renamer is not supported解决方案
生活随笔
收集整理的這篇文章主要介紹了
pandas.core.base.SpecificationError: nested renamer is not supported解决方案
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
利用pandas dataframe的groupby和agg方法寫詞頻統計代碼的時候,遇到的pandas版本迭代造成的原有代碼不可使用的情況。
遇到錯誤
pandas.core.base.SpecificationError: nested renamer is not supported問題代碼塊
words_stst = word_df.groupby(by='segment')['segment'].agg({'計數':'size'}) words_stst = words_stst.reset_index().sort_values(by=['計數'],ascending=False)解決方法
words_stst = word_df.groupby('segment').agg(計數=pd.NamedAgg(column='segment', aggfunc='size')).reset_index().sort_values(by='計數', 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解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 计算机系统在线安装,超详细的电脑装系统教
- 下一篇: 【已解决】Vue3+Element-pl