Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从写入器对象将工作表读取到数据帧_Python_Pandas_Openpyxl - Fatal编程技术网

Python 从写入器对象将工作表读取到数据帧

Python 从写入器对象将工作表读取到数据帧,python,pandas,openpyxl,Python,Pandas,Openpyxl,我有一个ExcelWriter对象,其中有几个工作表,这些工作表是从excel电子表格加载的。我现在想读出一张数据表作为数据帧。我知道我可以从原始excel电子表格中读取它,但我想从ExcelWriter对象中检索数据 正在使用openpyxl加载这些表 testwriter = pd.ExcelWriter(filename, engine = 'openpyxl') testwriter.book = openpyxl.load_workbook(filename) testwriter.s

我有一个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工作表转换为数据帧相当简单。尽管版本2.4将为此提供最佳支持,但所有版本的原则都是相同的:循环工作表中的行并返回单元格值

请参阅以获取一些想法

顺便说一句,不需要创建
testwriter.sheets
字典:使用'book['sheetname']