如何对 DataFrame 中的值进行排序

问题描述 投票:0回答:1

我有一些疑问。我得到了一些结果

poz = positiv[positiv["number"]>0].head(10)
poz

我得到了输出:

    number
abnormal    16
abolish 5
abominable  5
abomination 4
abort   1
aborted 6
abrasive    1
abrupt  6
abruptly    284
absence 10

但是我的结果是按字母顺序排列的,如何排序才能显示最常用的单词。我尝试使用 pd.nlargest 但结果与上面相同。

python pandas dataframe sorting
1个回答
1
投票

尝试使用

sort_values

poz = poz.sort_values('number',ascending=False).head(10)
© www.soinside.com 2019 - 2024. All rights reserved.