Python | Панды DatetimeIndex.is_month_end
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas DatetimeIndex.is_month_end attribute returns a numpy array containing logical values corresponding to each entries in the DatetimeIndex object. The value is set to True if the date is the last day of the month. Else the function returns False indicating the date is not the last day of the month.
Syntax: DatetimeIndex.is_month_end
Return: numpy array containing logical values.
Example #1: Use DatetimeIndex.is_month_end attribute to check if the dates present in the DatetimeIndex object is the last day of the month.
Выход :
Now we want to find if the dates contained in the given DatetimeIndex object is the last day of the month.
# find if the days are the last day of the month.didx.is_month_end |
Output :
As we can see in the output, the function has returned a numpy array containing logical values for each entry of the DatetimeIndex object. True values indicate the corresponding date was the last day of the month and False value indicate the corresponding date was not the last day of the month.
Example #2: Use DatetimeIndex.is_month_end attribute to check if the dates present in the DatetimeIndex object is the last day of the month.
# importing pandas as pdimport pandas as pd # Create the DatetimeIndexdidx = pd.DatetimeIndex(start ="2000-01-31 06:30", freq ="BM", periods = 5, tz ="Asia/Calcutta") # Print the DatetimeIndexprint(didx) |
Выход :
Now we want to find if the dates contained in the given DatetimeIndex object is the last day of the month.
# find if the days are the last day of the month.didx.is_month_end |
Output :
As we can see in the output, the function has returned a numpy array containing logical values for each entry of the DatetimeIndex object. True values indicate the corresponding date was the last day of the month and False value indicate the corresponding date was not the last day of the month.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.