Open
Description
I think this is really and edge case because in order to get this behavior you need to group by an external Series with the same name as one of the columns.
df = pd.DataFrame({"a": [1, 1, 2], "b": [3, 4, 5]})
print(df.groupby(pd.Series([6, 6, 7], name="a"), as_index=False).sum())
# a b
# 0 2 7
# 1 2 5
print(df.groupby(pd.Series([6, 6, 7], name="a"), as_index=True).sum().reset_index())
# ValueError: cannot insert a, already exists
I think users expect as_index=False
to behave the same as calling reset_index() after using as_index=True
. It is not good behavior that we silently drop the groupings when as_index=False
.