Python | Панды DatetimeIndex.freqstr
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas DatetimeIndex.freqstr attribute returns the frequency object as a string if it is set in the DatetimeIndex object. If the frequency is not set then it returns None.
Syntax: DatetimeIndex.freqstr
Return: frequency object as string
Example #1: Use DatetimeIndex.freqstr attribute to return the frequency object as a string for the given DatetimeIndex object.
Output :
Now we want to find the string value of frequency for the given DatetimeIndex object.
# find the value of frequency object as stringdidx.freqstr |
Output :
As we can see in the output, the function has returned the frequency object as string for the given DatetimeIndex object. ‘BQ’ represents business quarter and ‘DEC’ means it begins from the month of December.
Example #2: Use DatetimeIndex.freqstr attribute to find the frequency object as string for the given DatetimeIndex object.
# importing pandas as pdimport pandas as pd # Create the DatetimeIndex# Here "CBMS" represents custom business month start frequencydidx = pd.DatetimeIndex(start ="2000-01-10 06:30", freq ="CBMS", periods = 5, tz ="Asia/Calcutta") # Print the DatetimeIndexprint(didx) |
Выход :
Now we want to find the string value of frequency for the given DatetimeIndex object.
# find the value of frequency object as stringdidx.freqstr |
Выход :
Как мы видим в выходных данных, функция вернула объект частоты в виде строки для данного объекта DatetimeIndex. Объект didx DatetimeIndex имеет настраиваемую частоту начала рабочего месяца.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.