Reading an Excel named range into a pandas DataFrame

Viewed 13826

How can you read the data from a named range in Excel into a pandas DataFrame? Excel screenshot

Unfortunately, the canonical function pandas.read_excel() is designed to only read entire sheets within a workbook.

6 Answers

Here is the way I use openpyxl to copy a range in a [[]] :

wb = load_workbook(filename=xlPath)
ws, range= next(wb.defined_names["rangename"].destinations)
materials = [[cell.value for cell in row] for row in wb[ws][range]]
Related