pandas 分组统计

 import numpy as np

import pandas as pd

df=pd.read_excel(r'C:\Users\ruiying\Desktop\评审结果.xlsx')

df['xiang']=df['jgbm'].str[0:8]

df['xiang'].count()

df['xiang'].value_counts()

df[df['pdjb_bm']>=3]['pdjb_bm'].count()
df['xiang'].drop_duplicates().count()

df.describe()

result=df.groupby('xiang').apply(lambda x: x[x['pdjb_bm']>=3]['pdjb_bm'].count()).to_frame()
type(result)
result.head()
result.columns=['xiang','num']
result.describe()
result.columns
result.rename(columns={'xiang':'xian'},inplace=True)
result.to_csv(r'C:\Users\ruiying\Desktop\结.csv')

评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理