-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Description
Code Sample
df = pd.DataFrame({'A': [1.1,2.2], 'B':[1,2]})
df.groupby('B').A.transform(lambda x: True)This returns
Out[3]:
0 1.0
1 1.0
Name: A, dtype: float64
Problem
groupby.transform returns numeric values, not bool . This is inconsistent
because DataFrame.transform behaves differently:
In [5]: df.A.transform(lambda x:True)
Out[5]:
0 True
1 True
Name: A, dtype: boolAdditional
But please note that if the original data type is int, it works properly:
In [9]: df = pd.DataFrame({'A': [1,2], 'B':[1,2]})
...: df.groupby('B').A.transform(lambda x: True)
...:
Out[9]:
0 True
1 True
Name: A, dtype: bool