Friday, September 26, 2025
HomeLanguagesPython | Pandas DatetimeIndex.is_year_start

Python | Pandas DatetimeIndex.is_year_start

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.is_year_start attribute is an indicator for whether the date is the first day of the year. If the date is the first day of the year it returns True else it return False.

Syntax: DatetimeIndex.is_year_start

Return: numpy array containing logical values.

Example #1: Use DatetimeIndex.is_year_start attribute to check if the dates present in the DatetimeIndex object is the first day of the year.




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.DatetimeIndex(['2014-01-01', '2014-04-30', '2017-03-31', '2000-12-02'])
  
# Print the DatetimeIndex
print(didx)


Output :

Now we want to find if the dates contained in the given DatetimeIndex object is the first day of the year.




# find if the days are the first day of the year.
didx.is_year_start


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 first day of the year and False value indicate the corresponding date was not the first day of the year.
 
Example #2: Use DatetimeIndex.is_year_start attribute to check if the dates present in the DatetimeIndex object is the first day of the year.




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.date_range('2011-12-30', periods = 5)
  
# Print the DatetimeIndex
print(didx)


Output :

Now we want to find if the dates contained in the given DatetimeIndex object is the first day of the year.




# find if the days are the first day of the year.
didx.is_year_start


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 first day of the year and False value indicate the corresponding date was not the first day of the year.

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32320 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6683 POSTS0 COMMENTS
Nicole Veronica
11854 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6795 POSTS0 COMMENTS
Ted Musemwa
7071 POSTS0 COMMENTS
Thapelo Manthata
6755 POSTS0 COMMENTS
Umr Jansen
6762 POSTS0 COMMENTS