Skip to content

Commit

Permalink
code sample for pandas-dev#37641
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins committed Nov 9, 2020
1 parent d1a635d commit 14d2735
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bisect/37641.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pandas as pd

print(pd.__version__)


arrays = [["val1", "val1", "val2"], ["val1", "val1", "val2"]]
index = pd.MultiIndex.from_arrays(arrays, names=("idx1", "idx2"))

s = pd.Series([1, 2, 3], index=index)

res = s.groupby(["idx1", "idx2"], group_keys=False).rolling(1).mean()
print(res)

mi = pd.MultiIndex.from_tuples(
[("val1", "val1"), ("val1", "val1"), ("val2", "val2")], names=["idx1", "idx2"]
)

import pandas.testing as tm

tm.assert_index_equal(res.index, mi)

0 comments on commit 14d2735

Please sign in to comment.