From 55971a39c77295f81094616f2aaea5b6d684e973 Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 31 Mar 2023 00:13:03 -0400 Subject: [PATCH] CLN: Assorted cleanups --- pandas/core/groupby/groupby.py | 9 ++++----- pandas/tests/groupby/test_api_consistency.py | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index e591298e2a58e..9233a63452bfa 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -2832,11 +2832,6 @@ def blk_func(values: ArrayLike) -> ArrayLike: else: # We broadcast algorithms.take_nd analogous to # np.take_along_axis - - # Note: we only get here with backfill/pad, - # so if we have a dtype that cannot hold NAs, - # then there will be no -1s in indexer, so we can use - # the original dtype (no need to ensure_dtype_can_hold_na) if isinstance(values, np.ndarray): dtype = values.dtype if self.grouper.has_dropped_na: @@ -2844,6 +2839,10 @@ def blk_func(values: ArrayLike) -> ArrayLike: dtype = ensure_dtype_can_hold_na(values.dtype) out = np.empty(values.shape, dtype=dtype) else: + # Note: we only get here with backfill/pad, + # so if we have a dtype that cannot hold NAs, + # then there will be no -1s in indexer, so we can use + # the original dtype (no need to ensure_dtype_can_hold_na) out = type(values)._empty(values.shape, dtype=values.dtype) for i, value_element in enumerate(values): diff --git a/pandas/tests/groupby/test_api_consistency.py b/pandas/tests/groupby/test_api_consistency.py index ac5d0d23c7631..84988587cff3e 100644 --- a/pandas/tests/groupby/test_api_consistency.py +++ b/pandas/tests/groupby/test_api_consistency.py @@ -4,6 +4,8 @@ import inspect +import pytest + from pandas import ( DataFrame, Series, @@ -17,8 +19,8 @@ def test_frame_consistency(groupby_func): # GH#48028 if groupby_func in ("first", "last"): - # first and last are entirely different between frame and groupby - return + msg = "first and last are entirely different between frame and groupby" + pytest.skip(reason=msg) if groupby_func in ("cumcount", "ngroup"): assert not hasattr(DataFrame, groupby_func)