python dataframe groupby

功能:split-apply-combine,是分割,应用(count,sum,mean,mean,median),再聚合的应用,类似于sql中的group by

分割:分为分割对象和分割条件,分割对象是需要去统计的值,类似于sql中的count(user_id);分割条件是分割的依据,依据可以有多个,类似于sql中的group by col1,col2。

分割步骤:1.先指定分割对象再指定分割条件;2.先指定分割条件再指定分割对象 ;其中方法1指定分割条件的时候需要指定dataframe,其实只要指定好值即可。

猜你喜欢

转载自www.cnblogs.com/mango-lee/p/9456759.html