Skip to content

Conversation

@arw2019
Copy link
Contributor

@arw2019 arw2019 commented Dec 21, 2020

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

xref #38416 (comment)

@arw2019 arw2019 closed this Dec 21, 2020
@arw2019 arw2019 reopened this Dec 21, 2020
@arw2019 arw2019 added Typing type annotations, mypy/pyright type checking expressions pd.eval, query Needs Review labels Dec 21, 2020
def eval(
expr,
parser="pandas",
parser: str = "pandas",
Copy link
Member

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)

Copy link
Member

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

-------
DataFrame or None
DataFrame resulting from the provided query expression or
ndarray, scalar, pandas object, or None
Copy link
Member

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

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
Copy link
Member

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"?

@simonjayhawkins
Copy link
Member

@arw2019 can you address @jbrockmendel comments.

@jbrockmendel
Copy link
Member

Needs rebase and a couple of comments are outstanding, but otherwise I think this is pretty close.

@simonjayhawkins
Copy link
Member

@jbrockmendel over to you.

Copy link
Member

@MarcoGorelli MarcoGorelli left a 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)

@simonjayhawkins
Copy link
Member

@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]
Copy link
Member

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?

@simonjayhawkins
Copy link
Member

closing as stale.

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

Labels

expressions pd.eval, query Stale Typing type annotations, mypy/pyright type checking

4 participants