Skip to content

Commit 6cae820

Browse files
authored
CLN: Assorted cleanups (#52318)
1 parent 44eb283 commit 6cae820

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

pandas/core/groupby/groupby.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -2832,18 +2832,17 @@ def blk_func(values: ArrayLike) -> ArrayLike:
28322832
else:
28332833
# We broadcast algorithms.take_nd analogous to
28342834
# np.take_along_axis
2835-
2836-
# Note: we only get here with backfill/pad,
2837-
# so if we have a dtype that cannot hold NAs,
2838-
# then there will be no -1s in indexer, so we can use
2839-
# the original dtype (no need to ensure_dtype_can_hold_na)
28402835
if isinstance(values, np.ndarray):
28412836
dtype = values.dtype
28422837
if self.grouper.has_dropped_na:
28432838
# dropped null groups give rise to nan in the result
28442839
dtype = ensure_dtype_can_hold_na(values.dtype)
28452840
out = np.empty(values.shape, dtype=dtype)
28462841
else:
2842+
# Note: we only get here with backfill/pad,
2843+
# so if we have a dtype that cannot hold NAs,
2844+
# then there will be no -1s in indexer, so we can use
2845+
# the original dtype (no need to ensure_dtype_can_hold_na)
28472846
out = type(values)._empty(values.shape, dtype=values.dtype)
28482847

28492848
for i, value_element in enumerate(values):

pandas/tests/groupby/test_api_consistency.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import inspect
66

7+
import pytest
8+
79
from pandas import (
810
DataFrame,
911
Series,
@@ -17,8 +19,8 @@
1719
def test_frame_consistency(groupby_func):
1820
# GH#48028
1921
if groupby_func in ("first", "last"):
20-
# first and last are entirely different between frame and groupby
21-
return
22+
msg = "first and last are entirely different between frame and groupby"
23+
pytest.skip(reason=msg)
2224

2325
if groupby_func in ("cumcount", "ngroup"):
2426
assert not hasattr(DataFrame, groupby_func)

0 commit comments

Comments
 (0)