Getting an AttributeError: 'dict' object has no attribute 'parse' . While trying to read into multiple xlsx files

Getting an AttributeError: 'dict' object has no attribute 'parse' . While trying to read into multiple xlsx files

您好,我正在尝试将两个 excel 文件读取并打开到一个数据框中,但是我收到此错误。

AttributeError: 'dict' object has no attribute 'parse'

我的objective是用pandas把这两个xlsx文件合并成一个dataframe。我这个怎么办。帮助表示赞赏这是我的代码:

# 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 函数创建数据帧的字典(如果你传递 sheetname=None),不需要调用解析(因为没有 ExcelFile)。以前您必须创建一个 ExcelFile,然后解析每个 sheet。 参见 here

因此 reading_files 是 DataFrames 的字典列表...不清楚您要如何将其合并到 single-DataFrame(there's lots of choices!)。