我使用的 Panda 版本是 1.3.5,當我嘗試使用該sort_values功能時遇到錯誤。
代碼
founded_edvideos_list = find_matching_posts_forupdate(video_id_list, stop_at_page=stop_at_page)
founded_edvideos_df = pd.DataFrame(founded_edvideos_list)
founded_edvideos_df = pd.sort_values(by=['post_id'], ascending=True)
最后一行給出了一個錯誤
getattr__ raise AttributeError(f"module 'pandas' has no attribute '{name}'") AttributeError: module 'pandas' has no attribute 'sort_values'
當我列印資料框時,它如下所示,所以我應該能夠使用post_id. 我檢查了檔案,似乎找不到我的問題。
資料框
post_id title ... vid_type vid_record
0 12994 Trailblazer Melba Pattillo Beals ... [6923, 6926] [6929]
1 12992 Trailblazer Asha Prem ... [6923] [6929]
2 12894 Trailblazers Melisa Mujanovic and Nina Nukic ... [6923, 6926] [6929]
uj5u.com熱心網友回復:
您正在呼叫pandas.sort_values而不是sort_values呼叫pandas.Dataframe. 您的排序線應該是:
founded_edvideos_df = founded_edvideos_df.sort_values(by=['post_id'], ascending=True)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/435578.html
上一篇:計算串列內標簽的性能方法(熊貓)
下一篇:按月計算特定值
