Skip to content

BUG: UndefinedVariableError in DataFrame.query with classname #49248

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

Closed

Conversation

debnathshoham
Copy link
Member

@debnathshoham debnathshoham commented Oct 22, 2022

xref #47859

@debnathshoham debnathshoham marked this pull request as draft October 22, 2022 09:15
@debnathshoham debnathshoham marked this pull request as ready for review October 22, 2022 13:07
@debnathshoham debnathshoham changed the title UndefinedVariableError in DataFrame.query with classname BUG: UndefinedVariableError in DataFrame.query with classname Oct 24, 2022
@mroeschke mroeschke added the expressions pd.eval, query label Oct 24, 2022
@mroeschke
Copy link
Member

The doc build error may possibly be related? https://github.com/pandas-dev/pandas/actions/runs/3303682683/jobs/5451910616

@debnathshoham
Copy link
Member Author

Thanks for the feedback @mroeschke.
I see a lot of exceptions in user_guide/enhancingperf.rst, but I was able to build it locally without any error. Any advice how I can figure this out?

@mroeschke
Copy link
Member

Did you build the docs locally with the --warnings-are-errors flag?

@debnathshoham
Copy link
Member Author

I used both --warnings-are-errors --single user_guide/enhancingperf.rst, didn't throw any error.

@mroeschke
Copy link
Member

From the logs it appears that the errors are not just in --single user_guide/enhancingperf.rst so maybe try building the entire dogs with the --warnings-are-errors flag

@debnathshoham
Copy link
Member Author

I was able to replicate the error in the docs with that. But not able to identify why it's throwing ValueError in the docs, but not in the terminal for the exact same thing.

):
is_local = False
check = self.env.scope.get("column") == local_name
if not isinstance(check, Series) and check:
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't self.env.scope.get("column") == local_name always produce a bool?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, ideally it should.
Although the tests were fine, but it threw the error you mentioned up here #49248 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Not too familiar with this part of the codebase, but is there a way to check if it's local without checking if it's a series?

Copy link
Member Author

Choose a reason for hiding this comment

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

the error on the docs were specific to Series (either local_name or self.env.scope.get("column"))
One example below
Screenshot 2022-10-31 at 11 08 42 PM

Copy link
Member

Choose a reason for hiding this comment

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

Can the self.env.scope.get("column") Series name just be compared to the local_name?

Copy link
Member Author

@debnathshoham debnathshoham Oct 31, 2022

Choose a reason for hiding this comment

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

so something like

  • check if Series
  • compare self.env.scope["column"].name with local_name
  • if not Series compare directly self.env.scope["column"]

sorry but how is that any better?

EDIT: or did you mean just compare the Series.name? but for most cases, they aren't Series

Copy link
Member

Choose a reason for hiding this comment

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

(This may be my ignorance to this part of the code base), but I assumed that self.env.scope["column"] would refer to a Series object and the local_name would refer to the name of the Series so no Series checking needs to be done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, no that's not the case. Usually it's name of a df column.

I did the Series check just to cover the Sphinx errors. Maybe someone with better Sphinx knowledge can fix this more elegantly.

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Dec 13, 2022
@phillipuniverse
Copy link

phillipuniverse commented Dec 26, 2022

Should also fix #49248 #50442

@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expressions pd.eval, query Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: UndefinedVariableError in DataFrame.query if name is type
3 participants