【发布时间】:2019-06-09 07:09:59
【问题描述】:
我有一个数据框df2:
extention just_dates
0 d875679ds1.htm 2003-01-02
1 d875679ds1.htm 2015-10-31
2 form_s1a.htm 2015-11-01
3 form_s1a.htm 2015-11-01
4 form_s1a.htm 2015-11-01
5 form_s1a.htm 2015-11-01
6 d698362ds1a.htm 2015-11-01
7 d698362ds1a.htm 2015-11-01
8 form_s1a.htm 2015-11-01
9 form_s1a.htm 2015-11-01
10 form_s1a.htm 2015-11-01
11 d698362ds1a.htm 2015-11-01
12 form_s1a.htm 2015-11-01
13 form_s1a.htm 2015-11-01
14 form_s1a.htm 2015-11-01
15 d804420ds1a.htm 2015-11-01
16 d923792ds1a.htm 2015-11-02
17 d923792ds1a.htm 2015-11-02
18 d923792ds1a.htm 2015-11-02
19 a2221572zs-1.htm 2015-11-02
20 d938556df1.htm 2015-11-02
21 d938556df1.htm 2015-11-02
22 d938556df1.htm 2015-11-02
23 d938556df1.htm 2015-11-02
24 d766811ds1.htm 2015-11-02
25 d44564d8k.htm 2015-11-02
26 d776249ds1a.htm 2015-11-02
27 d776249ds1a.htm 2015-11-02
28 d776249ds1a.htm 2015-11-02
29 d776249ds1a.htm 2015-11-02
30 d776249ds1a.htm 2015-11-02
31 d776249ds1a.htm 2015-11-02
32 d776249ds1a.htm 2015-11-02
33 d776249ds1a.htm 2015-11-03
34 d776249ds1a.htm 2015-11-03
35 d776249ds1a.htm 2015-11-03
36 d938481ds1a.htm 2015-11-03
37 d766811ds1.htm 2015-11-03
38 d938481ds1a.htm 2015-11-03
39 d938481ds1a.htm 2015-11-03
40 d938481ds1a.htm 2015-11-03
41 d938481ds1a.htm 2015-11-03
42 d938481ds1a.htm 2015-11-03
43 d766811ds1.htm 2015-11-03
44 d946612ds1.htm 2015-11-04
45 forms-1a.htm 2015-11-04
46 forms-1a.htm 2015-11-04
用命令
out=[]
out.append(df2['just_dates'].value_counts().sort_index())
我变成了
2003-01-02 1
2015-10-31 1
2015-11-01 14
2015-11-02 17
2015-11-03 11
2015-11-04 3
这正是我想要的。它计算数据框df2 中每天的条目。但我的问题是我想要一个新的数据框out,我认为out 不是数据框,对吧?我认为这是因为我没有标题,也没有行号。我该怎么做才能成为一个新的数据框out?
【问题讨论】:
-
你需要
df.groupby('just_dates').size().reset_index(name='Count')