Skip to content

CLN: nanops #37396

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 4 commits into from
Oct 26, 2020
Merged
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
14 changes: 5 additions & 9 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,18 +381,16 @@ def _na_for_min_count(
if is_numeric_dtype(values):
values = values.astype("float64")
fill_value = na_value_for_dtype(values.dtype)
if fill_value is NaT:
fill_value = values.dtype.type("NaT", "ns")

if values.ndim == 1:
return fill_value
else:
assert axis is not None # assertion to make mypy happy
result_shape = values.shape[:axis] + values.shape[axis + 1 :]
# calling np.full with dtype parameter throws an ValueError when called
# with dtype=np.datetime64 and and fill_value=pd.NaT
try:
result = np.full(result_shape, fill_value, dtype=values.dtype)
except ValueError:
result = np.full(result_shape, fill_value)

result = np.full(result_shape, fill_value, dtype=values.dtype)
return result


Expand Down Expand Up @@ -526,11 +524,9 @@ def nansum(
def _mask_datetimelike_result(
result: Union[np.ndarray, np.datetime64, np.timedelta64],
axis: Optional[int],
mask: Optional[np.ndarray],
mask: np.ndarray,
orig_values: np.ndarray,
):
if mask is None:
mask = isna(orig_values)
if isinstance(result, np.ndarray):
# we need to apply the mask
result = result.astype("i8").view(orig_values.dtype)
Expand Down