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
ENH: KeyError from missing column should list available columns #50076
Comments
pandas DataFrames can have a massive number of columns which would either (a) overload the stdout or (b) we would need to truncate the output. Even when there are few colums, we'd need to worry about the repr of the individual columns being long themselves. |
Could check if if len(', '.join(df)) < some_treshold:
raise KeyError(f"['foo'] not in columns={', '.join(df)}") and make |
Yeah as is I would be -0.5 to include this given @rhshadrach concerns
|
More often than not column count and name lengths should be manageable, no?
Exactly, that's my use case! When a job fails and I only see it several hours later in a workflow with a dozen different dataframes, it can be hard to determine which data access is failing and how to fix it. I usually have to rerun the script interactively and print column names to determine the fix. |
Hey I'd like to work on this. Do we want to go ahead with making these changes? Or are we not fully sold on this idea yet. |
This needs more discussion first. I am also leaning more towards no. We don't want to have a million options |
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
Feature Description
The error message would be more helpful if it listed available columns:
Alternative Solutions
n/a
Additional Context
No response
The text was updated successfully, but these errors were encountered: