|
| 1 | +import sys |
| 2 | + |
1 | 3 | import pandas as pd
|
2 | 4 |
|
3 | 5 | print(pd.__version__)
|
|
12 | 14 | result = df.groupby(level=0)["Max Speed"].rolling(2).sum()
|
13 | 15 | print(result)
|
14 | 16 |
|
| 17 | +# expected = pd.MultiIndex.from_tuples( |
| 18 | +# [ |
| 19 | +# ("Falcon", "Falcon", "Captive"), |
| 20 | +# ("Falcon", "Falcon", "Wild"), |
| 21 | +# ("Parrot", "Parrot", "Captive"), |
| 22 | +# ("Parrot", "Parrot", "Wild"), |
| 23 | +# ], |
| 24 | +# names=["Animal", "Animal", "Type"], |
| 25 | +# ) |
| 26 | + |
15 | 27 | expected = pd.MultiIndex.from_tuples(
|
16 |
| - [ |
17 |
| - ("Falcon", "Falcon", "Captive"), |
18 |
| - ("Falcon", "Falcon", "Wild"), |
19 |
| - ("Parrot", "Parrot", "Captive"), |
20 |
| - ("Parrot", "Parrot", "Wild"), |
21 |
| - ], |
22 |
| - names=["Animal", "Animal", "Type"], |
| 28 | + [("Falcon",), ("Falcon",), ("Parrot",), ("Parrot",)], names=["Animal"] |
23 | 29 | )
|
24 | 30 |
|
25 | 31 | import pandas.testing as tm
|
26 | 32 |
|
27 |
| -tm.assert_index_equal(result.index, expected) |
| 33 | +try: |
| 34 | + tm.assert_index_equal(result.index, expected) |
| 35 | +except AssertionError: |
| 36 | + pass |
| 37 | +else: |
| 38 | + sys.exit(1) |
0 commit comments