padas操作

1、从excel读取数据

  pd.read_excel('naifen.xlsx')

2、保存为excel

  pd.to_excel('bb.xlsx')

3、统计某一列重复数据

  df.groupby(['地址'],as_index=False)['地址'].agg({'cnt':'count'})  ,这里统计的是地址列

4、统计某一列中小于某个数的数据

  df[df.price<100]  ,这里是统计price小于100的数据

5、对某一列求和

  df[df.price<100]['price'].sum() , 这里是对price小于100的数据中对price求和

6、去重

  drop_duplicates(subset=['A','B','C','D'],keep='first')   ,sunset表示列

  当keep=False时,就是去掉所有的重复行

  当keep=‘first'时,就是保留第一次出现的重复行

  当keep='last'时就是保留最后一次出现的重复行

猜你喜欢

转载自www.cnblogs.com/zhiduanqingchang/p/9724656.html