question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

read_excel throws ValueError: cannot specify usecols when specifying a multi-index header

See original GitHub issue
df=pd.read_excel(xl_file, sheet_name=xl_sheet,header=[18,19], usecols='B,D:J,L')

Problem description

df=pd.read_excel(xl_file, sheet_name=xl_sheet,header=[18,19], usecols=‘B,D:J,L’)

throws the following error after conda update:

ValueError: cannot specify usecols when specifying a multi-index header

The script run perfectly fine before.

Expected Output

Dataframe with multi-index columns, as before.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None python: 3.7.1.final.0 python-bits: 64 OS: Windows OS-release: 7 machine: AMD64 processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.24.1 pytest: 3.3.2 pip: 19.0.3 setuptools: 40.8.0 Cython: 0.27.3 numpy: 1.15.4 scipy: None pyarrow: None xarray: None IPython: 7.3.0 sphinx: 1.6.6 patsy: 0.5.0 dateutil: 2.8.0 pytz: 2018.9 blosc: None bottleneck: 1.2.1 tables: None numexpr: None feather: None matplotlib: 2.1.2 openpyxl: 2.4.10 xlrd: 1.1.0 xlwt: 1.3.0 xlsxwriter: 1.0.2 lxml.etree: None bs4: 4.6.0 html5lib: 1.0.1 sqlalchemy: 1.2.1 pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None gcsfs: None

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:24 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
kumfupandacommented, Mar 19, 2020

I also got the same issue

1reaction
akasolacecommented, May 18, 2021

this bug still exist on version 1.2.4 …

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas - read specific column of MultiIndex file - Stack Overflow
csv", sep='\t', header=[0, 1], index_col=0, usecols=["read_count"]) raises a ValueError: cannot specify usecols when specifying a multi-index ...
Read more >
IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
The header can be a list of ints that specify row locations for a MultiIndex on the columns e.g. [0,1,3] . Intervening rows...
Read more >
apache_beam.dataframe.io module - Apache Beam
The header can be a list of integers that specify row locations for a multi-index on the columns e.g. [0,1,3]. Intervening rows that...
Read more >
Working with MultiIndex in pandas DataFrame
Create MultiIndex pandas DataFrame (Multi level Index) ... The default setting for the parameter is drop=False which will keep the index ...
Read more >
Release 1.8.2 The Koalas Team
specified, and header and index are True, then the index names are used. A sequence should be given if the DataFrame uses MultiIndex....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found