Skip to content

Commit 4e86e6e

Browse files
added functionality to take negative values
1 parent fa0f78f commit 4e86e6e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pandas/core/index.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,9 @@ def insert(self, loc, item):
17871787
"""
17881788
_self = np.asarray(self)
17891789
item_idx = Index([item], dtype=self.dtype).values
1790+
#turn negative values into appropriate positive values
1791+
if loc < 0:
1792+
loc = len(_self[:loc]) + 1
17901793
idx = np.concatenate(
17911794
(_self[:loc], item_idx, _self[loc:]))
17921795
return Index(idx, name=self.name)

0 commit comments

Comments
 (0)