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
This seems very similar to the description of #16621, and may be the same bug; check there for some history, which points to an original fix in #2476. You can also look at this StackExchange question if you want to see how I nearly pulled my hair out.
The first call of .agg() above, on the empty DataFrame, produces a DataFrame result. The second call of .agg() produces a Series instead.
This has unfortunate implications when used with groupby():
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
This seems very similar to the description of #16621, and may be the same bug; check there for some history, which points to an original fix in #2476. You can also look at this StackExchange question if you want to see how I nearly pulled my hair out.
The first call of
.agg()
above, on the empty DataFrame, produces a DataFrame result. The second call of.agg()
produces a Series instead.This has unfortunate implications when used with
groupby()
:...produces:
...instead of:
Expected Output
I'm assuming that the call with data produces a series because the
agg()
is single-valued, therefore the top code should probably produce two Series:Actual output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: