|
9 | 9 | Period,
|
10 | 10 | PeriodIndex,
|
11 | 11 | Series,
|
| 12 | + Timedelta, |
| 13 | + Timestamp, |
12 | 14 | date_range,
|
13 | 15 | isna,
|
14 | 16 | )
|
@@ -296,6 +298,24 @@ def test_reindex_fill_value():
|
296 | 298 | tm.assert_series_equal(result, expected)
|
297 | 299 |
|
298 | 300 |
|
| 301 | +@pytest.mark.parametrize("dtype", ["datetime64[ns]", "timedelta64[ns]"]) |
| 302 | +@pytest.mark.parametrize("fill_value", ["string", 0, Timedelta(0)]) |
| 303 | +def test_reindex_fill_value_datetimelike_upcast(dtype, fill_value, using_array_manager): |
| 304 | + # https://github.com/pandas-dev/pandas/issues/42921 |
| 305 | + if using_array_manager: |
| 306 | + pytest.skip("Array manager does not promote dtype, hence we fail") |
| 307 | + |
| 308 | + if dtype == "timedelta64[ns]" and fill_value == Timedelta(0): |
| 309 | + # use the scalar that is not compatible with the dtype for this test |
| 310 | + fill_value = Timestamp(0) |
| 311 | + |
| 312 | + ser = Series([NaT], dtype=dtype) |
| 313 | + |
| 314 | + result = ser.reindex([0, 1], fill_value=fill_value) |
| 315 | + expected = Series([None, fill_value], index=[0, 1], dtype=object) |
| 316 | + tm.assert_series_equal(result, expected) |
| 317 | + |
| 318 | + |
299 | 319 | def test_reindex_datetimeindexes_tz_naive_and_aware():
|
300 | 320 | # GH 8306
|
301 | 321 | idx = date_range("20131101", tz="America/Chicago", periods=7)
|
|
0 commit comments