@@ -13,6 +13,7 @@ |
|
|
13 |
13 |
import pandas as pd |
14 |
14 |
from pandas import ( |
15 |
15 |
DataFrame, |
|
16 |
+Index, |
16 |
17 |
Series, |
17 |
18 |
) |
18 |
19 |
import pandas._testing as tm |
@@ -133,6 +134,21 @@ def test_xarray_cftimeindex_nearest(): |
|
|
133 |
134 |
assert result == expected |
134 |
135 |
|
135 |
136 |
|
|
137 |
+@td.skip_if_no("cftime") |
|
138 |
+@td.skip_if_no("xarray") |
|
139 |
+def test_xarray_cftimeindex_reset_index(): |
|
140 |
+import xarray |
|
141 |
+ |
|
142 |
+df = DataFrame( |
|
143 |
+ [[1, 2], [3, 4]], |
|
144 |
+columns=xarray.cftime_range("0001", periods=2), |
|
145 |
+index=Index(["hi", "bye"], name="string"), |
|
146 |
+ ) |
|
147 |
+# currently fails with TypeError |
|
148 |
+res = df.reset_index() |
|
149 |
+assert res.columns[0] == "string" |
|
150 |
+ |
|
151 |
+ |
136 |
152 |
def test_oo_optimizable(): |
137 |
153 |
# GH 21071 |
138 |
154 |
subprocess.check_call([sys.executable, "-OO", "-c", "import pandas"]) |