Closed
Description
__________________ TestGroupby.test_groupby_apply_identity ____________________
[gw0] linux -- Python 3.8.8 /home/vsts/miniconda3/envs/pandas-dev/bin/python
> raise TypeError("boolean value of NA is ambiguous")
E TypeError: boolean value of NA is ambiguous
pandas/_libs/missing.pyx:436: TypeError
The above exception was the direct cause of the following exception:
self = <pandas.tests.extension.test_boolean.TestGroupby object at 0x7f9eb07e2bb0>
data_for_grouping = <BooleanArray>
[True, True, <NA>, <NA>, False, False, True]
Length: 7, dtype: boolean
def test_groupby_apply_identity(self, data_for_grouping):
df = pd.DataFrame({"A": [1, 1, 2, 2, 3, 3, 1], "B": data_for_grouping})
result = df.groupby("A").B.apply(lambda x: x.array)
expected = pd.Series(
[
df.B.iloc[[0, 1, 6]].array,
df.B.iloc[[2, 3]].array,
df.B.iloc[[4, 5]].array,
],
index=pd.Index([1, 2, 3], name="A"),
name="B",
)
> self.assert_series_equal(result, expected)
pandas/tests/extension/test_boolean.py:335:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _