pandas 读取Excel 批量转换时间戳

一、安装

pip install pandas

如果出报错,不能运行,可以安装

 pip install xlrd

二、 代码如下

import pandas as pd
import time,datetime

file_path = r'C:\Users\Administrator\Desktop\携号转网测试\admin_log.xls'
df = pd.read_excel(file_path, sheet_name = "admin",header=None)
# print(df.values[1,0])
data=[]
for i in range(len(df)):
    timechuo = df.values[i,0]
    time_local = time.localtime(timechuo)
    dt = time.strftime("%Y-%m", time_local)
    data.append(dt)

result = pd.value_counts(data)
print(result)

猜你喜欢

转载自blog.csdn.net/weixin_47401101/article/details/129241083