Skip to content

Commit 6c25d56

Browse files
committed
fix failures
1 parent 8d91d4b commit 6c25d56

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

pandas/core/arrays/masked.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@
4242
from pandas.core.dtypes.common import (
4343
is_bool,
4444
is_dtype_equal,
45-
is_float_dtype,
4645
is_integer_dtype,
4746
is_list_like,
4847
is_scalar,
49-
is_signed_integer_dtype,
5048
is_string_dtype,
51-
is_unsigned_integer_dtype,
5249
pandas_dtype,
5350
)
5451
from pandas.core.dtypes.dtypes import BaseMaskedDtype
@@ -1112,19 +1109,19 @@ def _wrap_min_count_reduction_result(
11121109
self, name: str, result, skipna, min_count, **kwargs
11131110
):
11141111
if min_count == 0 and isinstance(result, np.ndarray):
1115-
return self._maybe_mask_result(result, np.zeros(1, dtype=bool))
1112+
return self._maybe_mask_result(result, np.zeros(result.shape, dtype=bool))
11161113
return self._wrap_reduction_result(name, result, skipna, **kwargs)
11171114

11181115
def _wrap_na_result(self, name):
11191116
mask = np.ones(1, dtype=bool)
11201117

1121-
if is_float_dtype(self.dtype):
1118+
if self.dtype.kind == "f":
11221119
np_dtype = np.float64
11231120
elif name in ["mean", "median", "var", "std", "skew"]:
11241121
np_dtype = np.float64
1125-
elif is_signed_integer_dtype(self.dtype):
1122+
elif self.dtype.kind == "i":
11261123
np_dtype = np.int64
1127-
elif is_unsigned_integer_dtype(self.dtype):
1124+
elif self.dtype.kind == "u":
11281125
np_dtype = np.uint64
11291126
else:
11301127
raise TypeError(self.dtype)

pandas/core/arrays/sparse/array.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,9 @@ def nonzero(self) -> tuple[npt.NDArray[np.int32]]:
13681368
# Reductions
13691369
# ------------------------------------------------------------------------
13701370

1371-
def _reduce(self, name: str, *, skipna: bool = True, **kwargs):
1371+
def _reduce(
1372+
self, name: str, *, skipna: bool = True, keepdims: bool = False, **kwargs
1373+
):
13721374
method = getattr(self, name, None)
13731375

13741376
if method is None:

pandas/tests/extension/base/dim2.py

+2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ def test_reductions_2d_axis0(self, data, method):
197197
if method in ["std", "var"]:
198198
# pass ddof=0 so we get all-zero std instead of all-NA std
199199
kwargs["ddof"] = 0
200+
elif method in ["prod", "sum"]:
201+
kwargs["min_count"] = 1
200202

201203
try:
202204
result = getattr(arr2d, method)(axis=0, **kwargs)

pandas/tests/groupby/test_apply.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,7 @@ def test_apply_multi_level_name(category):
944944
if category:
945945
b = pd.Categorical(b, categories=[1, 2, 3])
946946
expected_index = pd.CategoricalIndex([1, 2, 3], categories=[1, 2, 3], name="B")
947-
# GH#40669 - summing an empty frame gives float dtype
948-
expected_values = [20.0, 25.0, 0.0]
947+
expected_values = [20, 25, 0]
949948
else:
950949
expected_index = Index([1, 2], name="B")
951950
expected_values = [20, 25]

0 commit comments

Comments
 (0)