如何堆叠 value_count 和条形图的结果
How to stack the resuls from a value_count & bargraph
我有一个 value_count().sort_index() 基于伯尔尼州 'categorynumber'of .csv 文件的列
bern['categorynumber'].value_counts().sort_index()
结果是:
左|正确的
:---| ----:
1.1 | 781
1.2 | 185
1.3 | 319
1.4 | 79
1.5 |170
1.6 | 3个
1.7 | 20
2.1 |199
2.2 |856
2.3 | 63
2.4 |504
3.1 |139
3.2 |289
3.3 | 21
4.1 |366
4.2 | 276
4.3 |41
4.4 | 49
4.5 | 120
4.6 | 2285
4.7 | 478
5.1 | 65
5.2 | 137
5.3 | 75
5.4 | 46
名称:类别编号,数据类型:int64
现在我想
创建条形图
但是
df.plot (x = 'categorynumber', y = 数量, 种类 = 'bar')
似乎不起作用,因为我没有将正确的(在列中)计算定义为 'amount'
那我该怎么做呢?
根据 1.1-1.7 的总和创建 table 和条形图(图表); 2.1-2.4; 3.1-3.3; 4.1-4.7; 5.1-5.4可以吗?如果是,怎么做?
create a bargraph
but
df.plot (x = 'categorynumber', y = amount, kind = 'bar')
does not seem to function as I have not defined the right (in the column) calculations as 'amount'
so how do I do that?
显然 plot
函数比你更清楚要绘制什么,所以把它留给它并只指定 kind:
s.plot(kind='bar')
(我将你的 value_count().sort_index() s
命名为 df
因为它是 系列,不是DataFrame。)
- create a table and bars (graph) based on the sum of 1.1-1.7; 2.1-2.4; 3.1-3.3; 4.1-4.7; 5.1-5.4 is that possible? if yes, how?
在你的例子中,对象将被索引的整数部分分割,这很容易:
t = s.groupby(int).sum()
t.plot(kind='bar')
我有一个 value_count().sort_index() 基于伯尔尼州 'categorynumber'of .csv 文件的列
bern['categorynumber'].value_counts().sort_index()
结果是: 左|正确的 :---| ----: 1.1 | 781 1.2 | 185 1.3 | 319 1.4 | 79 1.5 |170 1.6 | 3个 1.7 | 20 2.1 |199 2.2 |856 2.3 | 63 2.4 |504 3.1 |139 3.2 |289 3.3 | 21 4.1 |366 4.2 | 276 4.3 |41 4.4 | 49 4.5 | 120 4.6 | 2285 4.7 | 478 5.1 | 65 5.2 | 137 5.3 | 75 5.4 | 46 名称:类别编号,数据类型:int64
现在我想
创建条形图 但是
df.plot (x = 'categorynumber', y = 数量, 种类 = 'bar') 似乎不起作用,因为我没有将正确的(在列中)计算定义为 'amount' 那我该怎么做呢?
根据 1.1-1.7 的总和创建 table 和条形图(图表); 2.1-2.4; 3.1-3.3; 4.1-4.7; 5.1-5.4可以吗?如果是,怎么做?
create a bargraph but
df.plot (x = 'categorynumber', y = amount, kind = 'bar') does not seem to function as I have not defined the right (in the column) calculations as 'amount' so how do I do that?
显然 plot
函数比你更清楚要绘制什么,所以把它留给它并只指定 kind:
s.plot(kind='bar')
(我将你的 value_count().sort_index() s
命名为 df
因为它是 系列,不是DataFrame。)
- create a table and bars (graph) based on the sum of 1.1-1.7; 2.1-2.4; 3.1-3.3; 4.1-4.7; 5.1-5.4 is that possible? if yes, how?
在你的例子中,对象将被索引的整数部分分割,这很容易:
t = s.groupby(int).sum()
t.plot(kind='bar')