In pandas, TimedeltaIndex represents an immutable array of time delta values, which can be used as an axis in a DataFrame or Series for representing differences in time.
The insert method of TimedeltaIndex is used to insert a new timedelta value at a particular position without modifying the original index.
Here's how you can use the insert method:
import pandas as pd # Create a TimedeltaIndex tdi = pd.TimedeltaIndex(['1 days', '3 days', '4 days']) # Insert a new timedelta at the second position (0-based index) new_tdi = tdi.insert(1, pd.Timedelta('2 days')) print(new_tdi) Output:
TimedeltaIndex(['1 days', '2 days', '3 days', '4 days'], dtype='timedelta64[ns]', freq=None)
In the above code:
TimedeltaIndex with values: 1 day, 3 days, and 4 days.insert method to insert '2 days' at the second position.TimedeltaIndex with values: 1 day, 2 days, 3 days, and 4 days.Note that the insert method returns a new TimedeltaIndex object and does not modify the original one, as TimedeltaIndex is immutable.
gitlab-ci linear-regression mktime superclass iokit http-headers docker-toolbox path-parameter servletconfig unique-id