Skip to content

Commit dc4d674

Browse files
committed
clean up min/max empty cases
1 parent c807f8e commit dc4d674

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

pandas/core/nanops.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -1068,18 +1068,13 @@ def reduction(
10681068
skipna: bool = True,
10691069
mask: npt.NDArray[np.bool_] | None = None,
10701070
) -> Dtype:
1071-
dtype = values.dtype
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-
result = getattr(values, meth)(axis, dtype=dtype_max)
1079-
result.fill(np.nan)
1080-
else:
1081-
result = getattr(values, meth)(axis)
1082-
1077+
result = getattr(values, meth)(axis)
10831078
result = _maybe_null_out(result, axis, mask, values.shape)
10841079
return result
10851080

0 commit comments

Comments
 (0)