A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/10417 below:

groupby with levels on duplicated multi-index · Issue #10417 · pandas-dev/pandas · GitHub

x = pd.DataFrame({'x':[1,1,3,3],'y':[3,3,5,5]},index=[11,11,12,12])
y = x.stack()
print(y)
print(y.groupby(level=[0,1]).sum())
11  x    1
    y    3
    x    1
    y    3
12  x    3
    y    5
    x    3
    y    5
dtype: int64
11  x    1
    y    3
    x    1
    y    3
12  x    3
    y    5
    x    3
    y    5
dtype: int64

The stack and group by sum are just the same.

11  x    2
11  y    6
12  x    6
12  y    10

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4