0

I have a dataframe 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 

With the command

out=[]
out.append(df2['just_dates'].value_counts().sort_index())

I become

2003-01-02     1
2015-10-31     1
2015-11-01    14
2015-11-02    17
2015-11-03    11
2015-11-04     3

what is exactly what I want to have. It counts the entry per day in the dataframe df2. But my problem ist that I want to have a new dataframe out and I think out is not a dataframe, right? I think this because I have no headlines and no rows numbers. What can I do to become a new dataframe out ?

Dennis
  • 195
  • 1
  • 2
  • 11

1 Answers1

0

Your output is a pd.series, you can convert it to a df with to_frame()

out = df2['just_dates'].value_counts().sort_index().to_frame()

for example:

d = {'col1': [1, 2,3,3,5,4,5], 'col2': [3, 4,5,4,6,6,7]}
df = pd.DataFrame(data=d)
df

Output:

  col1 col2
0   1   3
1   2   4
2   3   5
3   3   4
4   5   6
5   4   6
6   5   7

then

   df['col1'].value_counts().sort_index().to_frame()

Output:

    col1
1   1
2   1
3   2
4   1
5   2
Alperen Tahta
  • 459
  • 2
  • 12