Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between agg() and aggregate() function in pandas

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())
like image 649
Vyom Verma Avatar asked May 13 '26 13:05

Vyom Verma


1 Answers

The official documentation says

agg is an alias for aggregate. Use the alias.

It is the same.

like image 165
buhtz Avatar answered May 16 '26 23:05

buhtz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!