We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f9b6290 commit 23f5ce1Copy full SHA for 23f5ce1
pandas/core/groupby/groupby.py
@@ -1654,9 +1654,12 @@ def objs_to_bool(vals: ArrayLike) -> tuple[np.ndarray, type]:
1654
if is_object_dtype(vals.dtype):
1655
# GH#37501: don't raise on pd.NA when skipna=True
1656
if skipna:
1657
- vals = np.array([bool(x) if not isna(x) else True for x in vals])
+ func = np.vectorize(lambda x: bool(x) if not isna(x) else True)
1658
+ vals = func(vals)
1659
else:
- vals = np.array([bool(x) for x in vals])
1660
+ vals = vals.astype(bool, copy=False)
1661
+
1662
+ vals = cast(np.ndarray, vals)
1663
elif isinstance(vals, BaseMaskedArray):
1664
vals = vals._data.astype(bool, copy=False)
1665
0 commit comments