Python | Pandas TimedeltaIndex.append()
Last Updated :
28 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas TimedeltaIndex.append()
function appends a collection of index options together. More than one index object can be appended at a time by passing the indexes as a python list or tuple.
Syntax : TimedeltaIndex.append(other)
Parameters :
other : Index or list/tuple of indices
Return : appended : Index
Example #1: Use TimedeltaIndex.append()
function to append a TimedeltaIndex object at the end of the given object.
import pandas as pd
tidx1 = pd.TimedeltaIndex(start = '1 days 02:00:12.001124' , periods = 5 ,
freq = 'N' , name = 'Koala' )
tidx2 = pd.TimedeltaIndex(data = [ '-1 days 2 min 3us 10ns' ,
'1 days 06:05:01.000030' ,
'-1 days + 23:59:59.999999' ])
print (tidx1)
print (tidx2)
|
Output :
Now we will append tidx2 at the end of tidx1.
Output :
As we can see in the output, the TimedeltaIndex.append()
function has appended tidx2 at the end of tidx1.
Example #2: Use TimedeltaIndex.append()
function to append a list of TimedeltaIndex object at the end of the given object.
import pandas as pd
tidx1 = pd.TimedeltaIndex(start = '1 days 02:00:12.001124' , periods = 5 ,
freq = 'N' , name = 'Koala' )
tidx2 = pd.TimedeltaIndex(data = [ '-1 days 2 min 3us 10ns' ,
'1 days 06:05:01.000030' ,
'-1 days + 23:59:59.999999' ])
tidx3 = pd.TimedeltaIndex(data = [ '-3 days 02:10:00' ,
'1 days 06:05:01.000030' ,
'1 days 02:00:00' ], name = 'MyObjejct' )
print (tidx1)
print (tidx2)
print (tidx3)
|
Output :
Now we will append tidx2 and tidx3 at the end of tidx1.
tidx1.append([tidx2, tidx3])
|
Output :
As we can see in the output, the TimedeltaIndex.append()
function has appended tidx2 and tidx3 at the end of tidx1.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...