python:从熊猫枢轴的提取柱
我有一个枢轴桌子 total_chart = df.pivot_table(index =“ name”,values =“ tock”,aggfunc ='count')
> 输出使
A 8
B 52
C 24
D 6
E 43
F 5
G 13
I 1
我尝试仅获得第二列(仅数字) 有什么简单的方法吗?
I have a pivoted tabletotal_chart = df.pivot_table(index="Name", values="Items", aggfunc='count')
The output gives
A 8
B 52
C 24
D 6
E 43
F 5
G 13
I 1
I trying to get only the second column (number only)
Is there any simple way to get it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的代码应该为您带来技巧。
它计数“项目”,按索引“名称”排序,然后仅输出没有索引的计数。
The code below should do the trick for you.
It counts "Items", sort it ascending by the index "Name" and output just the counts without the index.