Skip to content

Commit 832bb05

Browse files
authored
CLN: remove unneeded try/except in nanops (#52684)
* CLN: remove unneded try/except in nanops * clean up min/max empty cases * remove return type
1 parent 1567d9e commit 832bb05

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

pandas/core/nanops.py

+5-13
Original file line numberDiff line numberDiff line change
@@ -1067,22 +1067,14 @@ def reduction(
10671067
axis: AxisInt | None = None,
10681068
skipna: bool = True,
10691069
mask: npt.NDArray[np.bool_] | None = None,
1070-
) -> Dtype:
1071-
dtype = values.dtype
1070+
):
1071+
if values.size == 0:
1072+
return _na_for_min_count(values, axis)
1073+
10721074
values, mask = _get_values(
10731075
values, skipna, fill_value_typ=fill_value_typ, mask=mask
10741076
)
1075-
1076-
if (axis is not None and values.shape[axis] == 0) or values.size == 0:
1077-
dtype_max = _get_dtype_max(dtype)
1078-
try:
1079-
result = getattr(values, meth)(axis, dtype=dtype_max)
1080-
result.fill(np.nan)
1081-
except (AttributeError, TypeError, ValueError):
1082-
result = np.nan
1083-
else:
1084-
result = getattr(values, meth)(axis)
1085-
1077+
result = getattr(values, meth)(axis)
10861078
result = _maybe_null_out(result, axis, mask, values.shape)
10871079
return result
10881080

0 commit comments

Comments
 (0)