Wednesday, October 22, 2025
HomeLanguagesPython | Pandas DatetimeIndex.is_month_start

Python | Pandas DatetimeIndex.is_month_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_month_start 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 first day of the month. Else the function returns False indicating the date is not the first day of the month.

Syntax: DatetimeIndex.is_month_start

Return: numpy array containing logical values.

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




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.DatetimeIndex(['2014-08-01', '2014-10-05',
                         '2015-04-01', '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 month.




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




# importing pandas as pd
import pandas as pd
  
# Create the DatetimeIndex
didx = pd.DatetimeIndex(start ='2000-01-10 06:30', freq ='CBMS', 
                              periods = 5, tz ='Asia/Calcutta')
  
# 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 month.




# find if the days are the first day of the month.
didx.is_month_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 month and False value indicate the corresponding date was not the first day of the month.

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

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS