df = pd.DataFrame(
[
["a", 1],
["a", 11],
["c", 12],
["c", 15]
],
columns=["col1","col2"]
)
grouped = df.groupby(["col1"])["col2"].sum().reset_index(name="ccc")
print(grouped)
(As example, taken from here)
This is bit unclear for me, how resetting index is related to aliasing/naming new aggregated column, but even more I don't get why this not raises: reset_index() got an unexpected keyword argument 'name'
error, because as doc says there is no "name" argument for reset_index()
.
Any help is appreciated