# -*- coding: utf-8 -*- import pandas as pd import os # 文件所在目录的路径 root = '日值数据集气温' # 获取目录下所有的文件名, 返回一个list file_name_list = os.listdir(root) df = pd.DataFrame() for file_name in file_name_list: file_name = root +'/' + file_name_list[0] print('正在添加:'+file_name) tmp = pd.read_excel(io=file_name) # 按行合并两个dataframe df = pd.concat([df,tmp],ignore_index=True) # 保存为pkl文件,方便下次读取 print('正在保存...') df.to_pickle('data.pkl')
import pandas as pd data = pd.read_pickle('data.pkl') print(data)