小编sak*_*uis的帖子

sort_values()得到了意外的关键字参数'by'

for i in str_list:   #str_list is a set contain some strings 
    df.loc[i].sort_values(by = 'XXX')
**TypeError**: sort_values() got an unexpected keyword argument 'by' ".
>>> type(df.loc[i])
>>> pandas.core.frame.DataFrame
Run Code Online (Sandbox Code Playgroud)

但是它在for循环之外起作用!

df.loc['string'].sort_values(by = 'XXX')
>>> type(df.loc['string'])
>>> pandas.core.frame.DataFrame
Run Code Online (Sandbox Code Playgroud)

我糊涂了。

python dataframe pandas

7
推荐指数
1
解决办法
8733
查看次数

标签 统计

dataframe ×1

pandas ×1

python ×1