Skip to content

Conversation

David-msggc
Copy link
Contributor

@David-msggc David-msggc commented Mar 31, 2025


if any(isinstance(col, int) for col in self.columns):
self = self.rename(
columns={col: f"{col}" for col in self.columns if isinstance(col, int)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be handled in clean_column_name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if I handle it in clean_column_name instead of in eval, wouldn't it return the same error since the integer column names would be ignored because of the line [ if not isinstance(k, int) ] in _get_cleaned_column_resolvers, thus not reaching the clean_column_name function. Maybe it can be handled in _get_cleaned_column_resolvers ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the if not isinstance(k, int) needs to be removed in _get_cleaned_column_resolvers instead. I would see what breaks if you remove that.

@mroeschke mroeschke added the expressions pd.eval, query label Mar 31, 2025
…ed_column_resolvers

Also removed the changes from the previous commit, which converted integer column names to strings
@mroeschke mroeschke added this to the 3.0 milestone Apr 1, 2025
@mroeschke mroeschke merged commit 4c5f4ca into pandas-dev:main Apr 1, 2025
42 checks passed
@mroeschke
Copy link
Member

Thanks @David-msggc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

expressions pd.eval, query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: df.query("1 == 0.1") failed with UndefinedVariableError: name 'BACKTICK_QUOTED_STRING_1' is not defined

2 participants