按产生值E的列对Pandas数据帧进行排序

2024-10-16 20:47:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图按特定列的值对pandas数据帧的行进行排序,但是我总是遇到一个我似乎无法理解的错误。我的数据框如下所示:

                                      Player                         PPG  \
0                           Hassan Whiteside                     39.5757   
1                               James Harden                     53.6047   
2                         Karl-Anthony Towns                     41.9976   
3                              DeMar DeRozan                     40.6075   
4                               Nikola Jokic                     30.0971   
5                                 Kyle Lowry                       39.94   
6                          Jonas Valanciunas                     26.0737   
7                          LaMarcus Aldridge                     30.9306   
8                              Julius Randle                      29.355   
9                              Kawhi Leonard                     39.2684   
10                              Jimmy Butler                     42.0975   
11                            Kenneth Faried                     22.6171   
12                           Emmanuel Mudiay                     22.5947   
13                               Brook Lopez                     32.1111   
14                              Goran Dragic                     32.1242   
15                                 Pau Gasol                     27.6921   
16                               Ricky Rubio                     25.8278   
17                            Lucas Nogueira                     16.7455   
18                            Andrew Wiggins                     30.2854   
19                          Danilo Gallinari                     26.6972   
20                               Dwyane Wade                     31.5108   
21                               Will Barton                     23.7259   
22                          D'Angelo Russell                     27.0781   
23                              Gorgui Dieng                     25.3951   
24                             James Johnson                      23.325   
25                           Harrison Barnes                       30.32   
26                             Dirk Nowitzki                     23.4267   
27                            Deron Williams                      26.225   
28                           Wilson Chandler                     28.0556   
29                               Robin Lopez                     21.5476   

我试着用PPG来分类:

^{pr2}$

它不断地抛出这个错误:

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

我试了很多次都没有成功,也不知道为什么会产生这个错误。在


Tags: 数据pandas排序错误karlanthonyplayerjames