-
- Notifications
You must be signed in to change notification settings - Fork 19.2k
TYP: pd.eval, DataFrame.(eval, query) #38625
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
Conversation
pandas/core/computation/eval.py Outdated
| def eval( | ||
| expr, | ||
| parser="pandas", | ||
| parser: str = "pandas", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonjayhawkins IIUC we can't use Literal yet. what if we used enums as a stopgap
class ParserStr(enum): pandas = "pandas" numexpr = "numexpr" that way we could start filling these in where appropriate and when we can use Literal swapping them out will be easy (wont require hunting them down)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we are now using Literal
pandas/core/frame.py Outdated
| ------- | ||
| DataFrame or None | ||
| DataFrame resulting from the provided query expression or | ||
| ndarray, scalar, pandas object, or None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"pandas object" means "Series or DataFrame" here? could confuse with PandasObject
pandas/core/frame.py Outdated
| DataFrame or None | ||
| DataFrame resulting from the provided query expression or | ||
| ndarray, scalar, pandas object, or None | ||
| The result of evaluation of the provided query expression or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"of evaluation of" -> "of evaluating"?
| @arw2019 can you address @jbrockmendel comments. |
| Needs rebase and a couple of comments are outstanding, but otherwise I think this is pretty close. |
| @jbrockmendel over to you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no default arguments preceding inplace in either of these functions, so they should be straightforward to overload - this would obviate the need for the casts you've added (no objection to this being done in a follow-up PR though)
Also, I think @jbrockmendel 's commented on having a preference for using # type: ignore rather than cast, especially if it's for something which can be fixed later (e.g. here it can be fixed with overloads)
| @MarcoGorelli feel free to push or otherwise close. I was going to close as stale but @jbrockmendel commented it was pretty close. #38625 (comment) |
| PythonFuncType = Callable[[Any], Any] | ||
| | ||
| IndexableEvalResult = Union[ArrayLike, FrameOrSeriesUnion] | ||
| EvalResult = Union[IndexableEvalResult, Scalar] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this meaningfully distinct from Any?
| closing as stale. |
black pandasgit diff upstream/master -u -- "*.py" | flake8 --diffxref #38416 (comment)