1

Here is the code.

import pandas as pd
df = pd.DataFrame({'Age':[0,0,1,14,15,30,31,50,51,79,78,45,22,15,80]})
print(df['Age']) 
a=df.groupby(['Age']).size()

print(a)

Output:

Age
0     2
1     1
14    1
15    2
22    1
30    1
31    1
45    1
50    1
51    1
78    1
79    1
80    1
dtype: int64

I want to get age as a first column and size as a second column into an array. How can i do that?

Sevval Kahraman
  • 1,185
  • 3
  • 10
  • 37

0 Answers0