Pandas returns "Passed header names mismatches usecols" error

It turns out there were 191 columns in the dataset (not 190). Pandas automatically set my first column of data as the index. I don't quite know why it caused it to error out since all of the columns in usecols were in fact present in the parsed in dataset.

So, the solution is to confirm that the number of columns in names exactly corresponds to the number of columns in your dataset.

Also, I found this discussion on GitHub.


For anyone out there debugging this error, it can also be caused if you forget a trailing comma in your list of column names. e.g.:

    columns = [
        'industry',
        'amount'
        'date',
        ...
    ]

Pandas will concatenate amount and date into a single amountdate, and of course the number of column names will be one lower than you expect.

Tags:

Python

Pandas