|
| 1 | +from importlib.metadata import version |
| 2 | + |
1 | 3 | import numpy as np |
2 | 4 | import pytest |
3 | 5 | from pandas import DataFrame, Index, MultiIndex, Series |
@@ -162,10 +164,17 @@ def test_df_group_str_str(df: DataFrame): |
162 | 164 | @pytest.mark.filterwarnings("ignore::FutureWarning") |
163 | 165 | def test_df_group_str_str_as_index_false(df: DataFrame): |
164 | 166 | a = df.groupby("x", as_index=False).agg("sum") |
165 | | - assert a.columns.to_list() == ["a", "b"] |
166 | | - assert a.index.to_list() == [0, 1] |
167 | | - assert a.index.name is None |
168 | | - np.testing.assert_array_equal(a, [[10, 50], [26, 66]]) |
| 167 | + if version("pandas").startswith("3."): |
| 168 | + assert a.columns.to_list() == ["x", "a", "b"] |
| 169 | + assert a.index.to_list() == [0, 1] |
| 170 | + assert a.index.name is None |
| 171 | + np.testing.assert_array_equal(a, [[1, 10, 50], [2, 26, 66]]) |
| 172 | + |
| 173 | + else: |
| 174 | + assert a.columns.to_list() == ["a", "b"] |
| 175 | + assert a.index.to_list() == [0, 1] |
| 176 | + assert a.index.name is None |
| 177 | + np.testing.assert_array_equal(a, [[10, 50], [26, 66]]) |
169 | 178 |
|
170 | 179 |
|
171 | 180 | def test_df_group_list_str(df: DataFrame): |
|
0 commit comments