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
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
df=pd.DataFrame(
[
("1", 1, 0, 0),
("2", 2, 0, 0),
("3", 3, 0, 0),
("4", 4, 5, 4),
("5", 5, 6, 6),
("6", 6, 7, 7),
],
columns=("item", "att1", "att2", "att3"),
)
defmyagg1(s):
returns.sum()
defmyagg2(s):
returns.sum() /2aggs1= ["sum", myagg1, "count", "min"]
aggs2= ["sum", myagg1, "count", "min"]
df.agg(aggs1) # order of the index is maintained# item att1 att2 att3# sum 123456 21 18 17# myagg1 123456 21 18 17# count 6 6 6 6# min 1 1 0 0df.agg(aggs2) # myagg2 returns nan and the result is sent to the last row# item att1 att2 att3# sum 123456 21.0 18.0 17.0# count 6 6.0 6.0 6.0# min 1 1.0 0.0 0.0# myagg2 NaN 10.5 9.0 8.5
Problem description
the order of the index on the resulting dataframe should not affected by the result of one of the aggregation functions.
Expected Output
df.agg(aggs2) # Regardless of the result the order is maintained# item att1 att2 att3# sum 123456 21.0 18.0 17.0# myagg2 NaN 10.5 9.0 8.5# count 6 6.0 6.0 6.0# min 1 1.0 0.0 0.0
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
Problem description
the order of the index on the resulting dataframe should not affected by the result of one of the aggregation functions.
Expected Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: