您好,我正在尝试读取两个 excel 文件并将其打开到一个数据框中,但出现此错误。
AttributeError: 'dict' object has no attribute 'parse'
我的目标是使用 pandas 并将这两个 xlsx 文件合并到一个数据框中。我这个怎么办。帮助表示赞赏这是我的代码如下:
# import modules
from IPython.display import display
import pandas as pd
import numpy as np
pd.set_option("display.max_rows", 999)
pd.set_option('max_colwidth',100)
%matplotlib inline
# filenames
file_names = ["data/OrderReport.xlsx", "data/OrderReport2.xlsx"]
reading_files = [(pd.read_excel(f, sheetname=None, parse_cols=None))for f in file_names]
frames = [x.parse(x.sheet_names[0], header=None,index_col=None) for x in reading_files]
请您参考如下方法:
使用"new"read_excel 函数,它会创建 DataFrames 的字典(如果您传递 sheetname=None),则无需调用解析(因为没有 ExcelFile)。以前,您必须创建一个 ExcelFile,然后解析每个工作表。 参见 here .
因此 reading_files 是 DataFrames 的字典列表...不清楚您希望如何将其合并到单个 DataFrame (there's lots of choices!)。
