Vyo*_*rma 6 pandas pandas-groupby
所以,我在 pandas 中经历了 agg() 和aggregate()。并发现两者都给出相似的输出。下面的代码为这两个函数提供了类似的输出。所以,只是想了解它们两者之间的区别。
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())
Run Code Online (Sandbox Code Playgroud)