You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pd.DataFrame({'x': [1, 1, 2, 2], 'y': [1, 2, 3, pd.NA]}).groupby('x').first()
# *** TypeError: boolean value of NA is ambiguouspd.DataFrame({'x': [1, 1, 2, 2], 'y': [1, 2, 3, np.nan]}).groupby('x').first()
# y# x # 1 1.0# 2 3.0pd.DataFrame({'x': [1, 1, 2, 2], 'y': [1, 2, 3, pd.NA]}).astype('Int64').groupby('x').first()
# y# x # 1 1# 2 3
Problem description
Applying the GroupBy.first aggregation to a object dtype column that contains a pd.NA causes the method to fail with an exception: TypeError: boolean value of NA is ambiguous. Method works fine when using np.nan and also works as expected when the column is first converted to an Int64 dtype column.
Code Sample
Problem description
Applying the
GroupBy.first
aggregation to aobject
dtype column that contains apd.NA
causes the method to fail with an exception:TypeError: boolean value of NA is ambiguous
. Method works fine when usingnp.nan
and also works as expected when the column is first converted to anInt64
dtype column.Expected Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: