【Pandas】sum与count

import numpy as np
import pandas as pd


df = pd.DataFrame({'Animal': ['Falcon', 'Falcon',
                              'Parrot', 'Parrot'],
                   'Max Speed': [380., 370., 24., 26.]})
df 

【Pandas】sum与count_第1张图片

count

count_sta = df[['Animal', 'Max Speed']].groupby(['Animal'],as_index=False).count()
count_sta

 【Pandas】sum与count_第2张图片

 sum

sum_sta = df[['Animal', 'Max Speed']].groupby(['Animal'],as_index=False).sum()
sum_sta

【Pandas】sum与count_第3张图片

 

 

你可能感兴趣的:(Hive,&,Sql,&,Spark,pandas)