Python | Панды DatetimeIndex.is_year_end
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas DatetimeIndex.is_year_end attribute is an indicator for whether the date is the last day of the year. If the date is the last day of the year it returns True else it return False.
Syntax: DatetimeIndex.is_year_end
Returns: numpy array containing logical values.
Example #1: Use DatetimeIndex.is_year_end attribute to check if the dates present in the DatetimeIndex object is the last day of the year.
Выход :
Now we want to find if the dates contained in the given DatetimeIndex object is the last day of the year.
# find if the days are the last day of the year.didx.is_year_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 year and False value indicate the corresponding date was not the last day of the year.
Example #2: Use DatetimeIndex.is_year_end attribute to check if the dates present in the DatetimeIndex object is the last day of the year.
# importing pandas as pdimport pandas as pd # Create the DatetimeIndexdidx = pd.date_range("2017-12-30", periods = 5) # Print the DatetimeIndexprint(didx) |
Выход :
Now we want to find if the dates contained in the given DatetimeIndex object is the last day of the year.
# find if the days are the last day of the year.didx.is_year_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 year and False value indicate the corresponding date was not the last day of the year.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.