以下内容转自 数析学院,只节选了部分,有需要的同学可以直接查看原文
- import pandas as pd
- import matplotlib
- import os
- import sys
- %matplotlib inline
1、创建 3 个 excel 文件
- # 创建 DataFrame
- d = {'Channel':[1], 'Number':[255]}
- df = pd.DataFrame(d)
- df
- # 输出到 Excel
- df.to_excel('test1.xlsx', sheet_name = 'test1', index = False)
- df.to_excel('test2.xlsx', sheet_name = 'test2', index = False)
- df.to_excel('test3.xlsx', sheet_name = 'test3', index = False)
- print('Done')
2、将所有 Excel 文件放入 DataFrame 中
获取文件名列表,确保该文件夹中没有其他 excel 文件。
- # 放置文件名的 list
- FileNames = []
- # 请读者根据实际情况请修改下面的路径
- os.chdir(r"C:\Users\david\notebooks")
- # 找到所有以 ".xlsx" 结尾的文件
- for files in os.listdir("."):
- if files.endswith(".xlsx"):
- FileNames.append(files)
-
- FileNames
以上内容转自 数析学院,后续内容有时间再补齐,有需要的同学可以直接查看原文


雷达卡




京公网安备 11010802022788号







