-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
Consider allowing negative values for loc parameter of DatetimeIndex.insert(loc, item). Currently, negative parameters result in an "off by 1" return value. For example:
In [ 1]: index = pandas.DatetimeIndex(start = '01/01/2000', freq = 'B', periods = 5) In [ 2]: dt = pandas.Timestamp('01/01/2013') In [ 3]: new_ind = index.insert(-1, dt) In [ 4]: new_ind[-1] Out[ 4]: Timestamp('2000-01-07 00:00:00', tz=None) But:
In [ 5]: new_ind[-2] Out[ 5]: Timestamp('2013-01-01 00:00:00', tz=None) I can put together a quick fork if it's a change you'd like. If not, I think it makes sense to change the docstring to say that "negative values are not allowed."