BUG: DataFrameGroupBy.transform unnecessarily coerces dtype #42617
Labels
Apply
Apply, Aggregate, Transform, Map
Bug
Dtype Conversions
Unexpected or buggy dtype conversions
Groupby
Uh oh!
There was an error while loading. Please reload this page.
Comparing
gives
Note that in the first result, the dtype of a starts and ends as integer, whereas in the 2nd, the dtype starts as integer and ends as float.
When the object column (c) is on the frame, we call
_transform_item_by_item
which operates on each column individually, giving the expected dtype in the result. Without the object column, we take the slowpath calling apply. apply returns a Series whose index is ['a', 'b'] with values [0.0, 0.0], where the dtype of column b coerces the dtype of column a into the final result of all floats.The first example above is deprecated (will raise in a future version), but the second example will still be valid and result in the wrong dtype.
The text was updated successfully, but these errors were encountered: