We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9a211aa commit 839e7f1Copy full SHA for 839e7f1
pandas/core/indexes/timedeltas.py
@@ -163,7 +163,7 @@ def __new__(
163
"represent unambiguous timedelta values durations."
164
)
165
166
- if isinstance(data, TimedeltaArray):
+ if isinstance(data, TimedeltaArray) and freq is None:
167
if copy:
168
data = data.copy()
169
return cls._simple_new(data, name=name, freq=freq)
pandas/tests/indexes/timedeltas/test_constructors.py
@@ -47,6 +47,12 @@ def test_infer_from_tdi_mismatch(self):
47
# GH#23789
48
TimedeltaArray(tdi, freq="D")
49
50
+ with pytest.raises(ValueError, match=msg):
51
+ TimedeltaIndex(tdi._data, freq="D")
52
+
53
54
+ TimedeltaArray(tdi._data, freq="D")
55
56
def test_dt64_data_invalid(self):
57
# GH#23539
58
# passing tz-aware DatetimeIndex raises, naive or ndarray[datetime64]
0 commit comments