Skip to content

Commit 6f419a8

Browse files
Remove test_groupby_agg_extension (marked xfail) (#54272)
* Remove test_groupby_agg_extension (marked xfail) Remove special `test_groupby_agg_extension` in `test_json.py` as we can now pass the test generally with these fixes to `GroupBy.first` and `GroupBy.last`. Signed-off-by: Michael Tiemann <[email protected]> * Update v2.1.0.rst Fix sort order. Signed-off-by: Michael Tiemann <[email protected]> * Apply suggestions from code review Incorporate suggestions from @mroeschke (consolidating docs and fixing a malformed return statement). Signed-off-by: Michael Tiemann <[email protected]> Co-authored-by: Matthew Roeschke <[email protected]> --------- Signed-off-by: Michael Tiemann <[email protected]> Co-authored-by: Matthew Roeschke <[email protected]>
1 parent a32a328 commit 6f419a8

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

doc/source/whatsnew/v2.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ Other
688688
- Bug in :meth:`DataFrame.reindex` with a ``fill_value`` that should be inferred with a :class:`ExtensionDtype` incorrectly inferring ``object`` dtype (:issue:`52586`)
689689
- Bug in :meth:`DataFrame.shift` and :meth:`Series.shift` and :meth:`DataFrameGroupBy.shift` when passing both "freq" and "fill_value" silently ignoring "fill_value" instead of raising ``ValueError`` (:issue:`53832`)
690690
- Bug in :meth:`DataFrame.shift` with ``axis=1`` on a :class:`DataFrame` with a single :class:`ExtensionDtype` column giving incorrect results (:issue:`53832`)
691+
- Bug in :meth:`GroupBy.first` and :meth:`GroupBy.last` where an empty group would return ``np.nan`` instead of a an ExtensionArray's NA value (:issue:`39098`)
691692
- Bug in :meth:`Index.sort_values` when a ``key`` is passed (:issue:`52764`)
692693
- Bug in :meth:`Series.align`, :meth:`DataFrame.align`, :meth:`Series.reindex`, :meth:`DataFrame.reindex`, :meth:`Series.interpolate`, :meth:`DataFrame.interpolate`, incorrectly failing to raise with method="asfreq" (:issue:`53620`)
693694
- Bug in :meth:`Series.argsort` failing to raise when an invalid ``axis`` is passed (:issue:`54257`)

pandas/core/groupby/groupby.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3279,7 +3279,7 @@ def first(x: Series):
32793279
"""Helper function for first item that isn't NA."""
32803280
arr = x.array[notna(x.array)]
32813281
if not len(arr):
3282-
return np.nan
3282+
return x.array.dtype.na_value
32833283
return arr[0]
32843284

32853285
if isinstance(obj, DataFrame):
@@ -3338,7 +3338,7 @@ def last(x: Series):
33383338
"""Helper function for last item that isn't NA."""
33393339
arr = x.array[notna(x.array)]
33403340
if not len(arr):
3341-
return np.nan
3341+
return x.array.dtype.na_value
33423342
return arr[-1]
33433343

33443344
if isinstance(obj, DataFrame):

pandas/tests/extension/json/test_json.py

-4
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,6 @@ def test_groupby_extension_no_sort(self):
356356
"""
357357
super().test_groupby_extension_no_sort()
358358

359-
@pytest.mark.xfail(reason="GH#39098: Converts agg result to object")
360-
def test_groupby_agg_extension(self, data_for_grouping):
361-
super().test_groupby_agg_extension(data_for_grouping)
362-
363359

364360
class TestArithmeticOps(BaseJSON, base.BaseArithmeticOpsTests):
365361
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):

0 commit comments

Comments
 (0)