数据框的Barh方法未根据参数绘制正确的数据

时间:2019-11-02 22:44:53

标签: python dataframe plot

我正在尝试使用DataFrame类的 barh 方法绘制一些数据。但是,似乎给该方法的参数表不会改变数据的显示方式。简而言之,我正在尝试绘制 fields_arrondissement datasetid

  fields_arrondissement  datasetid  ...  fields_complementadresse  fields_varieteoucultivar
0       BOIS DE BOULOGNE         15  ...                         5                         1
1      BOIS DE VINCENNES         66  ...                         1                         2
2         HAUTS-DE-SEINE         28  ...                         1                         2
3        PARIS 10E ARRDT         16  ...                         8                         5
4        PARIS 11E ARRDT         29  ...                         3                         3
5        PARIS 12E ARRDT         53  ...                         9                        14
6        PARIS 13E ARRDT         82  ...                         3                        24
7        PARIS 14E ARRDT         48  ...                         8                         9
8        PARIS 15E ARRDT         95  ...                        46                        29
9        PARIS 16E ARRDT         95  ...                        13                         9
10       PARIS 17E ARRDT         52  ...                         8                        14
11       PARIS 18E ARRDT         40  ...                         5                         9
12       PARIS 19E ARRDT         63  ...                         4                         8
13       PARIS 1ER ARRDT          8  ...                         0                         1
14       PARIS 20E ARRDT         60  ...                        15                         8
15        PARIS 3E ARRDT          3  ...                         2                         1
16        PARIS 4E ARRDT         11  ...                         0                         1
17        PARIS 5E ARRDT         10  ...                         6                         0
18        PARIS 6E ARRDT         11  ...                         3                         3
19        PARIS 7E ARRDT         55  ...                        29                        12
20        PARIS 8E ARRDT         38  ...                        10                         6
21        PARIS 9E ARRDT          7  ...                         4                         1
22     SEINE-SAINT-DENIS         64  ...                         0                        15
23          VAL-DE-MARNE         51  ...                         0                         8

这是我用来完成所需内容的代码段:

        pd_groupby = pd_arbre.groupby('fields_arrondissement')
        count_arbre = pd_groupby.count().reset_index()
        count_arbre = count_arbre[count_arbre['fields_arrondissement'].str.contains('PARIS', regex=False)] 
        count_arbre.sort_values(by=['fields_arrondissement'])
        count_arbre.recordid.plot.barh(ax=ax2, x="fields_arrondissement", y="record_id", grid=True, color="green")

最后,这是我运行代码时屏幕上显示的内容: I want to replace the element on the vertical axis by the **fields_arrondissement**

如您所见,水平轴确实正确。但是,垂直栏不显示第一列的元素

0 个答案:

没有答案