Skip to content

Commit 0540671

Browse files
jbrockmendeljreback
authored andcommitted
BUG: TDI.insert with empty TDI raising IndexError (pandas-dev#30757)
1 parent 09bd172 commit 0540671

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/indexes/timedeltas/test_indexing.py

+9
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ def test_take_fill_value(self):
173173

174174

175175
class TestTimedeltaIndex:
176+
def test_insert_empty(self):
177+
# Corner case inserting with length zero doesnt raise IndexError
178+
idx = timedelta_range("1 Day", periods=3)
179+
td = idx[0]
180+
181+
idx[:0].insert(0, td)
182+
idx[:0].insert(1, td)
183+
idx[:0].insert(-1, td)
184+
176185
def test_insert(self):
177186

178187
idx = TimedeltaIndex(["4day", "1day", "2day"], name="idx")

0 commit comments

Comments
 (0)