常用

2018-11-12  本文已影响0人  SummerTan

1 python读取 excel

 data= xlrd.open_workbook('/home/Desktop/批量升级.xlsx')

   table = data.sheets()[0]

   ncols = table.ncols

   rt_list = table.col_values(0)

   rt_list = [i.encode('utf-8') for i in rt_list]

2 写excel

主要代码如下:

from pandas import DataFrame

data={

'name':['张三','李四','王五'],

'age':[11,12,13]

'sex':'男','女','男']

}

df=DataFrame(data)

df.to_excel('new.xlsx",sheet_name='XXX')

3 pandas df filter

# 每5min采样

df = df[df.apply(lambda x:int(str(x['timestamp'])[-5:-3])/5==0,axis=1)]

上一篇 下一篇

猜你喜欢

热点阅读