Python | Pandas DatetimeIndex.inferred_freq
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 DatetimeIndex.inferred_freq
attribute tries to return a string representing a frequency guess, generated by infer_freq. For those cases in which the function is not able to auto detect the frequency of the DatetimeIndex it returns None.
Syntax: DatetimeIndex.inferred_freq
Return: freq
Example #1: Use DatetimeIndex.inferred_freq
attribute to auto detect the frequency of the given DatetimeIndex object.
import pandas as pd
didx = pd.date_range( "2008-12-30" , periods = 5 , freq = 'Q' )
print (didx)
|
Output :
Now we want the function to auto detect the frequency of the given DatetimeIndex object.
Output :
As we can see in the output, the function has tried to auto detect the frequency of the given DatetimeIndex object and has returned a quarter type frequency starting from the month of December.
Example #2: Use DatetimeIndex.inferred_freq
attribute to auto detect the frequency of the given DatetimeIndex object.
import pandas as pd
didx = pd.DatetimeIndex(start = '2000-01-31 06:30' , freq = 'BM' ,
periods = 5 , tz = 'Asia/Calcutta' )
print (didx)
|
Output :
Now we want the function to auto detect the frequency of the given DatetimeIndex object.
Output :
As we can see in the output, the function has tried to auto detect the frequency of the given DatetimeIndex object and has returned ‘BM’ (Business Month end) frequency.
Last Updated :
24 Dec, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...