Open In App

Python | Pandas TimedeltaIndex.isin

Improve
Improve
Like Article
Like
Save
Share
Report

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.isin() function compute a boolean array of whether each index value is found in the passed set of values or not. If the index value is found in the passed value then it is marked True else it is marked False.

Syntax : TimedeltaIndex.isin(values)

Parameters :
values : set or sequence of values

Return : is_contained : ndarray (boolean dtype)

Example #1: Use TimedeltaIndex.isin() function to check if the elements of the given TimedeltaIndex object is present in the passed list of values.




# importing pandas as pd
import pandas as pd
  
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(start ='11 days 22:14:12.001124',
               periods = 5, freq ='T', name ='New_object')
  
# Print the TimedeltaIndex object
print(tidx)


Output :

Now we will use the TimedeltaIndex.isin() function to find if the index labels are present in the passed list or not.




# check if labels are present in the passed list
tidx.isin(['11 days 22:16:12.001124', '11 days 22:17:12.001124'])


Output :

As we can see in the output, the TimedeltaIndex.isin() function has returned an array object of boolean values. Object contains True values corresponding to those elements are present in the passed list and False values for those which are not present in the passed list.
 
Example #2: Use TimedeltaIndex.isin() function to check if the elements of the given TimedeltaIndex object is present in the passed list of values.




# importing pandas as pd
import pandas as pd
  
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['06:05:01.000030', '3 days 06:05:01.000030'
                                '22 day 2 min 3us 10ns', '+23:59:59.999999',
                             '13 days 06:05:01.000030', '+12:19:59.999999'])
  
# Print the TimedeltaIndex object
print(tidx)


Output :

Now we will use the TimedeltaIndex.isin() function to find if the index labels are present in the passed list or not.




# check if labels are present in the passed list
tidx.isin(['0 days 23:59:59.999999', '13 days 06:05:01.000030'])


Output :

As we can see in the output, the TimedeltaIndex.isin() function has returned an array object of boolean values. Object contains True values corresponding to those elements are present in the passed list and False values for those which are not present in the passed list.



Last Updated : 28 Dec, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads