这是一个创建于 2826 天前的主题,其中的信息可能已经有所发展或是发生改变。
import pandas as pd
c=pd.DataFrame({'a':[1,2,3,1,2,1,1,1,1]})
c.groupby('a').count()
--------
理论上应该有这个结果:
a amount
1 6
2 2
3 1
----------
然鹅,是这个:
Empty DataFrame
Columns: []
Index: [1, 2, 3]
-------------------
为什么呢?
如果要形成想要的结果,应该怎么写呀,我想不明白哪儿错了
 | | 1 enenaaa 2018 年 7 月 30 日 a 当了 groupby 的条件之后, 变成结果的索引了呀,dataframe 又没有其他的列,所以返回的数据为空。 |
 | | 2 shenxgan 2018 年 7 月 30 日 #1 1 楼说的很对 可以这样做: |