-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: Usecols do not match columns, columns expected but not found: ['Col3', 'Col1'] #59139
Comments
Thanks for the report! The documentation states: "If |
I think this is a discrepancy to the other referenced sentence see my report, in the documentation. |
Well yes, you can pass a list of the column names just as the documentation states. But it also states that if |
Stupid behavior. Not consistent in my opinion. |
If your CSV file has the columns Can you share why you think it's inconsistent? If you passed |
That works I agree, but in a use case where you have 25 columns in the input csv and you need only the 1st and maybe the 23th, you have to name 25 new columns that you can usecols by column name (what's still in the csv). I think this is ineffective. |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
This is still a bug! If I read the documentation it said clearly: "For example, a valid list-like usecols parameter would be [0, 1, 2] or ['foo', 'bar', 'baz']."
If I use it as described I get: "ValueError: Usecols do not match columns, columns expected but not found: ['Col3', 'Col1']". Only [0,1,2] index is working! This ERROR message is also misleading/ wrong.
Expected Behavior
As the documentation describe the behavior. usecase: https://stackoverflow.com/a/78681763/12621346
If I would read according old column names and rename it to new names this works only with index 1, 2, 3 and not column names.
Installed Versions
2.0.3
The text was updated successfully, but these errors were encountered: