So, I was going through agg() and aggregate() in pandas. And found both to give similar output. Here is the code which gives similar output for both the functions. So, just wanted to understand wat is the difference between both of them.
data = {'Name': ['Giggs', 'Tom', 'Dick', 'Harry', 'Jack', 'Jill', 'Scholes', 'Martial', 'Rashford', 'Pogba'],
'Age': [23,21,24,21,20,10,23,45,22,35],
'Rating': [4.23, 3.21, 2.10, 1.91, 4.32, 6.32, 4.19, 2.09, 1.09, 3.33],
'Teams': ['Man Utd',"PSG",'Real Madrid','Real Madrid', 'Man Utd', 'Man City','Man City','PSG','Man Utd','PSG'],
'Year': [2014, 2015, 2014, 2015, 2014, 2015, 2016, 2017, 2016, 2014]}
df = pd.DataFrame(data)
print(grouped.agg('Rating').sum())
print("------Aggregation function---")
print(grouped.aggregate('Rating').sum())
The official documentation says
aggis an alias foraggregate. Use the alias.
It is the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With