我有一个用例,其中必须读取具有多个标题列和值的xl文件。
import pandas as pd
workbook_loc = "c:\\2020\Book1.xlsx"
df = pd.read_excel(workbook_loc, sheet_name=None)
data_dict = df.to_dict()
but the above script is throwing out AttributeErro 'dict' object has no attribute.
what is the wrong I am doing?
。
{{1}}
答案 0 :(得分:0)
当您指定 sheet_name = None 时,它将返回字典而不是pandas数据框。指定工作表名称始终是一种很好的做法。
您可以尝试一下。
all_years = []
for fyp in finished_years_proper:
with open(fyp, 'r') as year:
for line in year:
... # your regex search on year
all_years.append(xxx)