相关疑难解决方法(0)

Pandas Python:对数据框进行排序但不包括给定的行

我有 df 看起来像这样:

Label                      Base
Label                          
Très à gauche              4.51
Très à droite             10.49
Ni à gauche, ni à droite  24.21
Je ne sais pas             5.60
Au centre                  8.69
A gauche                  23.74
A droite                  22.75
Run Code Online (Sandbox Code Playgroud)

我想按升序排序,但我不希望排序中包含“A gauche”和“A droite”。

下面的代码做了我想要的,但我不确定如何从排序中排除“A gauche”和“A droite”。

 df_table = df_table.sort(columns="Base",ascending=True)
Run Code Online (Sandbox Code Playgroud)

预期产出

Label                      Base
Label                          
Très à gauche              4.51
Je ne sais pas             5.60
Au centre                  8.69
Très à droite             10.49
Ni à gauche, ni à droite  24.21
A gauche                  23.74
A droite                  22.75
Run Code Online (Sandbox Code Playgroud)

谢谢

python sorting dataframe pandas

2
推荐指数
1
解决办法
2386
查看次数

标签 统计

dataframe ×1

pandas ×1

python ×1

sorting ×1