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.is_all_dates
attribute return a boolean value. It returns True
if the TimedeltaIndex object contains only dates.
Syntax: TimedeltaIndex.is_all_dates
Return : boolean
Example #1: Use TimedeltaIndex.is_all_dates
attribute to check if the TimedeltaIndex object contains only dates.
# 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 check if the TimedeltaIndex object contains only date.
# check if tidx contains date tidx.is_all_dates |
Output :
As we can see in the output, the TimedeltaIndex.is_all_dates
attribute has returned True
indicating that tidx contain all date values.
Example #2: Use TimedeltaIndex.inferred_type
attribute to check if the TimedeltaIndex object contains only dates.
# 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 check if the TimedeltaIndex object contains only date.
# check if tidx contains date tidx.is_all_dates |
Output :
As we can see in the output, the TimedeltaIndex.is_all_dates
attribute has returned True
indicating that tidx contain all date values.