我有一个pandas ExcelWriter对象,其中有几个工作表,它们是从excel电子表格加载的。我现在想读出一个数据帧。我知道我可以从原始的excel电子表格中读取它,但是我想从ExcelWriter对象中检索数据。在
正在使用openpyxl加载工作表
testwriter = pd.ExcelWriter(filename, engine = 'openpyxl')
testwriter.book = openpyxl.load_workbook(filename)
testwriter.sheets = dict((ws.title, ws) for ws in book.worksheets)
dataframe = pd.DataFrame(testwriter.sheets['sheetname']) ???
将现有的openpyxl工作表转换为Pandas数据帧非常简单。虽然2.4版将提供最好的支持,但所有版本的原则都是一样的:循环工作表中的行并返回单元格值。
请参阅openpyxl 2.4 documentation for working with Pandas了解一些想法。
顺便说一句,不需要创建
testwriter.sheets
字典:使用`book['sheetname']。相关问题 更多 >
编程相关推荐