BUG: 1.3.0 DataFrame.agg over categorical columns with non-unique index returns wrong size result #42380
Closed
2 of 3 tasks
Labels
Apply
Apply, Aggregate, Transform, Map
Regression
Functionality that used to work in a prior pandas version
Milestone
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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Using pandas 1.2.5:
Using pandas 1.3.0:
It does not look like this is an issue if I use
df.apply
instead ofdf.agg
.Problem description
When a aggregation of the rows is run on a dataframe with categorical columns and non-unique indices, the result is the wrong length.
It's weird that the output isn't the right length. Since I'm computing a value per row, I expect the same number of rows in the output as in the input. It's especially weird that this only happens if the columns are categorical.
That is:
in both versions.
Expected Output
I would expect the same output between versions. The result given by 1.2.5 seems more correct to me at the moment.
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: