pandas.read_excel index_col argument behavior seems to be wrong (or unexpected, as by the docs)
See original GitHub issuehttp://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html#pandas.read_excel
It’s about the parameter index_col.
From the docs, I read
index_col : int, list of ints, default None
Column (0-indexed) to use as the row labels of the DataFrame. Pass None if there is no such column. If a list is passed, those columns will be combined into a MultiIndex"
I use the function with args={index_col=3, parse_cols=“D-J”} (so it should parse from column 3 to column 9 included, 0-indexed). And I expected D to be used as Index, but actually it was column G. I am not sure if it is the expected behavior, if then, maybe argument order should be changed to show that index_col depends on parsed_cols.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
read_excel surprisingly filling empty levels in MultiIndex ...
This behavior was introduced in #10967. pandas is forward filling index columns under the assumption that the excel sheet was written from a...
Read more >pandas.read_excel — pandas 0.24.0rc1 documentation
If a list is passed, those columns will be combined into a MultiIndex . If a subset of data is selected with usecols...
Read more >python - panda read_excel index_col seems to skip a row
I am trying to get a multi level index and column pandas data frame from an excel file, but oddly it ...
Read more >Pandas read_excel() - Reading Excel File in Python
The sheet_name parameter defines the sheet to be read from the excel file. When we print the DataFrame object, the output is a...
Read more >Pandas - read_excel() - How to read Excel file in python
To do that we need to pass the sheet name to the sheet_name parameter in pandas. df = pd.read_excel('reading_excel_file.xlsx', sheet_name=' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d expand the explanation of
index_col
in theread_excel
docstring here https://github.com/pandas-dev/pandas/blob/697d0269aa6903be75db97afb45f9976abd2406d/pandas/io/excel.py#L85And them maybe add an example to the narrative docs, somewhere around here http://pandas.pydata.org/pandas-docs/stable/io.html#parsing-specific-columns
(by changing this file): https://github.com/pandas-dev/pandas/blob/697d0269aa6903be75db97afb45f9976abd2406d/doc/source/io.rst
@chris-b1 I shall work on it. But I’m more interested in some coding issue. Could you suggest some for starters?