Read Excel Table headers with xlwings

2019-07-26 23:46发布

How can I use xlwings to read a "table" in excel, into a pandas DataFrame, where the table "headers" become the DataFrame column names?

Every way I have tried to read the table, the header row is always excluded from the read!

Here is what I've tried, where "b" is my xlwings workbook object:

b.sheets['Sheet1'].range('Table1').options(pd.DataFrame)
b.sheets['Sheet1'].range('Table1').options(pd.DataFrame, headers=False)
b.sheets['Sheet1'].range('Table1').options(pd.DataFrame, headers=True)

1条回答
forever°为你锁心
2楼-- · 2019-07-27 00:20

Hoping this is not the best answer, but I did find I could reference the named range, then .offset(-1).expand('vertical')

查看更多
登录 后发表回答