BUG: Fix GroupBy.idxmin/idxmax retrun wrong type on empty by luke396 · Pull Request #51423 · pandas-dev/pandas (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can't dtype directly to all result, because there are some types can't be converted to each other, such as inf and NA.

Therefore, I tried to convert only the empty result. Based on the original code, the type is incorrect only when the return value is empty.

@jbrockmendel any suggestion?