Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support uncertainties as EA Dtype #53970

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3272,7 +3272,10 @@ def first(x: Series):
"""Helper function for first item that isn't NA."""
arr = x.array[notna(x.array)]
if not len(arr):
return np.nan
MichaelTiemannOSC marked this conversation as resolved.
Show resolved Hide resolved
nan_arr = x.array[isna(x.array)]
if not len(nan_arr):
return np.nan
return nan_arr[0]
return arr[0]

if isinstance(obj, DataFrame):
Expand Down Expand Up @@ -3331,7 +3334,10 @@ def last(x: Series):
"""Helper function for last item that isn't NA."""
arr = x.array[notna(x.array)]
if not len(arr):
return np.nan
nan_arr = x.array[isna(x.array)]
if not len(nan_arr):
return np.nan
return nan_arr[-1]
return arr[-1]

if isinstance(obj, DataFrame):
Expand Down
4 changes: 0 additions & 4 deletions pandas/tests/extension/json/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,6 @@ def test_groupby_extension_no_sort(self):
"""
super().test_groupby_extension_no_sort()

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


class TestArithmeticOps(BaseJSON, base.BaseArithmeticOpsTests):
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/extension/test_boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def data_for_twos(dtype):

@pytest.fixture
def data_missing(dtype):
return pd.array([np.nan, True], dtype=dtype)
return pd.array([pd.NA, True], dtype=dtype)


@pytest.fixture
Expand All @@ -58,7 +58,7 @@ def data_for_sorting(dtype):

@pytest.fixture
def data_missing_for_sorting(dtype):
return pd.array([True, np.nan, False], dtype=dtype)
return pd.array([True, pd.NA, False], dtype=dtype)


@pytest.fixture
Expand All @@ -76,7 +76,7 @@ def na_value():
def data_for_grouping(dtype):
b = True
a = False
na = np.nan
na = pd.NA
return pd.array([b, b, na, na, a, a, b], dtype=dtype)


Expand Down Expand Up @@ -147,7 +147,7 @@ def _check_op(self, obj, op, other, op_name, exc=NotImplementedError):
expected = expected.astype("Float64")
if op_name == "__rpow__":
# for rpow, combine does not propagate NaN
expected[result.isna()] = np.nan
expected[result.isna()] = pd.NA
self.assert_equal(result, expected)
else:
with pytest.raises(exc):
Expand Down
Loading