Skip to content

CLN: Pass numpy args as kwargs #33789

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

Merged
merged 1 commit into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pandas/compat/numpy/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,16 @@ def validate_cum_func_with_skipna(skipna, args, kwargs, name):
STAT_FUNC_DEFAULTS["dtype"] = None
STAT_FUNC_DEFAULTS["out"] = None

PROD_DEFAULTS = SUM_DEFAULTS = STAT_FUNC_DEFAULTS.copy()
SUM_DEFAULTS = STAT_FUNC_DEFAULTS.copy()
SUM_DEFAULTS["axis"] = None
SUM_DEFAULTS["keepdims"] = False
SUM_DEFAULTS["initial"] = None

PROD_DEFAULTS = STAT_FUNC_DEFAULTS.copy()
PROD_DEFAULTS["axis"] = None
PROD_DEFAULTS["keepdims"] = False
PROD_DEFAULTS["initial"] = None

Comment on lines +259 to +263
Copy link
Member Author

Choose a reason for hiding this comment

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

Small nitpick but it feels more clear to modify these separately / explicitly rather than updating both dicts with a single assignment

MEDIAN_DEFAULTS = STAT_FUNC_DEFAULTS.copy()
MEDIAN_DEFAULTS["overwrite_input"] = False
MEDIAN_DEFAULTS["keepdims"] = False
Expand Down
30 changes: 4 additions & 26 deletions pandas/core/arrays/numpy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,36 +365,14 @@ def max(self, skipna: bool = True, **kwargs) -> Scalar:
)
return result

def sum(
self,
axis=None,
dtype=None,
out=None,
keepdims=False,
initial=None,
skipna=True,
min_count=0,
):
nv.validate_sum(
(), dict(dtype=dtype, out=out, keepdims=keepdims, initial=initial)
)
def sum(self, axis=None, skipna=True, min_count=0, **kwargs) -> Scalar:
nv.validate_sum((), kwargs)
return nanops.nansum(
self._ndarray, axis=axis, skipna=skipna, min_count=min_count
)

def prod(
self,
axis=None,
dtype=None,
out=None,
keepdims=False,
initial=None,
skipna=True,
min_count=0,
):
nv.validate_prod(
(), dict(dtype=dtype, out=out, keepdims=keepdims, initial=initial)
)
def prod(self, axis=None, skipna=True, min_count=0, **kwargs) -> Scalar:
nv.validate_prod((), kwargs)
return nanops.nanprod(
self._ndarray, axis=axis, skipna=skipna, min_count=min_count
)
Expand Down