Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';在Python中找不到聚合结果列_Python_Pandas - Fatal编程技术网

Can';在Python中找不到聚合结果列

Can';在Python中找不到聚合结果列,python,pandas,Python,Pandas,“计数”列在哪里?我想您正在寻找值\u计数 s = pd.Series(["08-10-2017", "08-10-2017", "08-10-2017", "09-10-2017", "09-10-2017", "09-10-2017", "10-10-2017", "10-10-2017", "10-10-2017", "11-10-2017", "11-10-2017", "11-10-2017", "12-10-2017", "12-10-2017", "12-10-2017", "13

“计数”列在哪里?

我想您正在寻找
值\u计数

s = pd.Series(["08-10-2017", "08-10-2017", "08-10-2017", "09-10-2017", "09-10-2017", "09-10-2017", "10-10-2017", "10-10-2017", "10-10-2017", "11-10-2017", "11-10-2017", "11-10-2017", "12-10-2017", "12-10-2017", "12-10-2017", "13-10-2017", "13-10-2017", "13-10-2017", "14-10-2017", "14-10-2017"])
p = pd.DataFrame(data=s)
p.columns = ['date']
p.groupby('date').agg('count').reset_index().columns
如果你想和groupby打交道

p.date.value_counts()
Out[1095]: 
09-10-2017    3
13-10-2017    3
10-10-2017    3
12-10-2017    3
08-10-2017    3
11-10-2017    3
14-10-2017    2
Name: date, dtype: int64
如果你想使用count

p.groupby('date').size()

你能把你得到的结果加起来吗?
p.groupby('date').agg({'date':'count'})
Out[1101]: 
            date
date            
08-10-2017     3
09-10-2017     3
10-10-2017     3
11-10-2017     3
12-10-2017     3
13-10-2017     3
14-10-2017     2