Skip to content

Commit e2f988d

Browse files
skipna keyword not yet available in groupby for 2.3
1 parent f64275e commit e2f988d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pandas/core/arrays/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,8 +2391,7 @@ def _groupby_op(
23912391
if op.how == "sum":
23922392
# https://github.com/pandas-dev/pandas/issues/60229
23932393
# All NA should result in the empty string.
2394-
assert "skipna" in kwargs
2395-
if kwargs["skipna"] and min_count == 0:
2394+
if min_count == 0:
23962395
arr = arr.fillna("")
23972396
npvalues = arr.to_numpy(object, na_value=np.nan)
23982397
else:

pandas/tests/groupby/test_reductions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,13 @@ def test_min_empty_string_dtype(func, string_dtype_no_object):
711711

712712

713713
@pytest.mark.parametrize("min_count", [0, 1])
714-
def test_string_dtype_empty_sum(string_dtype_no_object, skipna, min_count):
714+
def test_string_dtype_empty_sum(string_dtype_no_object, min_count):
715715
# https://github.com/pandas-dev/pandas/issues/60229
716716
dtype = string_dtype_no_object
717717
df = DataFrame({"a": ["x"], "b": [pd.NA]}, dtype=dtype)
718718
gb = df.groupby("a")
719-
result = gb.sum(skipna=skipna, min_count=min_count)
720-
value = "" if skipna and min_count == 0 else pd.NA
719+
result = gb.sum(min_count=min_count)
720+
value = "" if min_count == 0 else pd.NA
721721
expected = DataFrame(
722722
{"b": value}, index=pd.Index(["x"], name="a", dtype=dtype), dtype=dtype
723723
)

0 commit comments

Comments
 (0)