You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks @WillAyd - taking this up now. I also checked out all other reductions, it appears only min and max have incorrect behavior.
One I'll note is that idxmin and idxmax return float NaN, but I think this is expected. This is because these are returning index values which are integers. When one changes the index to string, we do indeed return string dtype as well.
pd.set_option("infer_string", True)
df=pd.DataFrame({"a": "a", "b": pd.array(3*[None], dtype="str")}, index=["x", "y", "z"])
print(df.groupby("a").idxmin())
# b# a # a NaNprint(df.groupby("a").idxmin().dtypes)
# b str# dtype: object
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
The sum reduction return type is partially discussed in #60229 but I didn't see anything for
min
Note that this discrepancy is the root cause of the test failure shown at
pandas/pandas/tests/resample/test_resampler_grouper.py
Line 465 in dec6eb2
@rhshadrach
Expected Behavior
I think in all cases here we should still be returning a
str
type.Installed Versions
'3.0.0.dev0+1824.g8d6d29cac3.dirty'
The text was updated successfully, but these errors were encountered: