BUG: groupby.transform with a reducer and unobserved categories coerces dtype #55326
Labels
Bug
Categorical
Categorical Data Type
Dtype Conversions
Unexpected or buggy dtype conversions
Groupby
Transformations
e.g. cumsum, diff, rank
Uh oh!
There was an error while loading. Please reload this page.
The implementation of groupby.transform with a reduction like
sum
ormin
calls the corresponding reduction and then reindexes the output to the input's index in_wrap_transform_fast_result
. However, when there are unobserved categories, their presence can induce NA values in the reduction, coercing the dtype to float. This results in unnecessarily coercing the result to float as well.The expected output of column
b
here should be [3, 3, 5] rather than floats.The text was updated successfully, but these errors were encountered: