Python Bytes - Panda Dataframe Groupby Sum Mean Std

Published: 08 May 2023
on channel: AC
555
6

#Coded by Andrew
import pandas as pd
import numpy as np

ipl_data = {'Team': ['Riders', 'Riders', 'Devils', 'Devils', 'Kings',
'Kings', 'Kings', 'Kings', 'Riders', 'Royals', 'Royals', 'Riders'],
'Rank': [1, 2, 2, 3, 3,4 ,1 ,1,2 , 4,1,2],
'Year': [2014,2015,2014,2015,2014,2015,2016,2017,2016,2014,2015,2017],
'Points':[876,789,863,673,741,812,756,788,694,701,804,690]}

df = pd.DataFrame(ipl_data)

grouped = df.groupby('Team')

print (grouped['Points'].agg([np.sum, np.mean, np.std]))


Watch video Python Bytes - Panda Dataframe Groupby Sum Mean Std online without registration, duration hours minute second in high quality. This video was added by user AC 08 May 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 555 once and liked it 6 people.