qiita.rb
df = pd.DataFrame({'Animal': ['Falcon', 'Falcon',
'Parrot', 'Parrot','Parrot'],
'Max Speed': [380., 370., 24., 26.,27.],'Annimal_ID': [1, 1,2,2,2]})
df
Groupby Use when you want to process the same group.
qiita.rb
#Used when you want to do the same for Falcon and Parrot groups
df.groupby(['Animal']).mean()
qiita.rb
#Check the size
df.groupby(['Animal']).size()
qiita.rb
#Get size
Falcon_num=df.groupby(['Animal']).size()['Falcon']
print(Falcon_num)
qiita.rb
#Get size
#Get data for a specific group
df.groupby(['Animal']).get_group('Falcon')
Recommended Posts