Skip to content
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

DEPR: Replacing builtin and NumPy funcs in agg/apply/transform #53974

Merged
merged 2 commits into from Jul 7, 2023

Conversation

rhshadrach
Copy link
Member

@rhshadrach rhshadrach added Deprecate Functionality to remove in pandas Apply Apply, Aggregate, Transform labels Jul 2, 2023
func: Callable,
alias: str,
) -> None:
if alias.startswith("np."):
Copy link
Member

Choose a reason for hiding this comment

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

Will this warn correctly is a user passes numpy.sum or builtins.sum?

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 - we use lookups in _builtin_table_alias and _cython_table to identify the function the user passes, so it is independent of any binding (e.g numpy.sum vs np.sum). The alias here arises from the values in these two dictionaries, and so must either start with np. or just be the op name (e.g. "sum")

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, but we will report that pandas is using e.g. np.sum regardless of how the user imports NumPy. So the warning will be emitted under the correct circumstances, but the message might not align with how they import. I think the message is still clear though.

Copy link
Member

Choose a reason for hiding this comment

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

Okay. Yeah I think the message is clear enough despite how the user imports numpy

@mroeschke mroeschke added this to the 2.1 milestone Jul 7, 2023
@mroeschke mroeschke merged commit 6b4254e into pandas-dev:main Jul 7, 2023
34 checks passed
@mroeschke
Copy link
Member

Thanks @rhshadrach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: Special casing of NumPy and Python builtin functions
2 participants