Python | Pandas TimedeltaIndex.inferred_type

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.inferred_type attribute return an inferred type for the object on which it is applied.
Syntax: TimedeltaIndex.inferred_type
Return : inferred_type
Example #1: Use TimedeltaIndex.inferred_type attribute to infer the type of the TimedeltaIndex object.
# importing pandas as pd import pandas as pd # Create the TimedeltaIndex object tidx = pd.TimedeltaIndex(data =['1 days 02:00:00', '1 days 06:05:01.000030', None]) # Print the TimedeltaIndex print(tidx) |
Output :
Now we will guess the type of the given TimedeltaIndex object.
# return the inferred type of the tidx object tidx.inferred_type |
Output :
As we can see in the output, the TimedeltaIndex.inferred_type attribute has returned ‘timedelta64’ type for tidx object.
Example #2: Use TimedeltaIndex.inferred_type attribute to infer the type of the TimedeltaIndex object.
# importing pandas as pd import pandas as pd # Create the TimedeltaIndex object tidx = pd.TimedeltaIndex(data =['-1 days 2 min 3us', '1 days 06:05:01.000030', '-1 days + 23:59:59.999999']) # Print the TimedeltaIndex print(tidx) |
Output :
Now we will guess the type of the given TimedeltaIndex object.
# return the inferred type of the tidx object tidx.inferred_type |
Output :
As we can see in the output, the TimedeltaIndex.inferred_type attribute has returned ‘timedelta64’ type for tidx object.




