We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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
groupby.transform returns numeric values, not bool . This is inconsistent because DataFrame.transform behaves differently:
groupby.transform
DataFrame.transform
In [5]: df.A.transform(lambda x:True) Out[5]: 0 True 1 True Name: A, dtype: bool
But please note that if the original data type is int, it works properly:
int
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
The text was updated successfully, but these errors were encountered:
Looks essentially the same as #10972, which was closed by #15430, but apparently didn't capture this case. apply does do the right inference here:
apply
In [2]: df.groupby('B').A.apply(lambda x: True) Out[2]: B 1 True 2 True Name: A, dtype: bool
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Code Sample
This returns
Problem
groupby.transform
returns numeric values, not bool . This is inconsistentbecause
DataFrame.transform
behaves differently:Additional
But please note that if the original data type is
int
, it works properly:The text was updated successfully, but these errors were encountered: