我使用的熊猫版本是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'
当我打印dataframe时,它看起来如下所示,所以我应该能够使用post_id。我检查了文件,似乎找不到我的问题。
dataframe
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]发布于 2022-03-01 18:37:13
您正在调用pandas.sort_values,而不是调用pandas.Dataframe实例上的sort_values。您的排序线应该是:
founded_edvideos_df = founded_edvideos_df.sort_values(by=['post_id'], ascending=True)
https://stackoverflow.com/questions/71313111
复制相似问题