Python | Pandas DatetimeIndex.is_month_end



DatetimeIndex.is_month_end Pandas DatetimeIndex.is_month_end returns an empty array containing boolean values ​​corresponding to each entry in a DatetimeIndex object. The value is set to True if the date is the last day of the month. Otherwise, the function returns False indicating that the date is not the last day of the month.

Syntax: DatetimeIndex.is_month_end

Return: numpy array containing logical values.

Example # 1: Use the DatetimeIndex.is_month_end attribute to check if the dates in the DatetimeIndex are the last day of the month.

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex

didx = pd.DatetimeIndex ([ `2014-01-31` , ` 2014-02-28`

`2015-04-01` , ` 2000-12-02` ])

 
# Print DatetimeIndex

print (didx)

Output:

Now we want to find out if the dates contained in this DatetimeIndex are the last day of the month.

# define whether the days are the last day of the month.
didx.is_month_end

Output:

As we can see in the output, the function returned an empty array containing boolean values ​​for each object record DatetimeIndex.  True values ​​indicate that the corresponding date was the last day of the month, and False values ​​indicate that the corresponding date was not the last day of the month.

Example # 2: Use the DatetimeIndex.is_month_end attribute to check if the dates in the DatetimeIndex are the last day of the month.

# import pandas as pd

import pandas as pd

 
# Create DatetimeIndex

didx = pd.DatetimeIndex (start = `2000-01-31 06:30` , freq = `BM`

periods = 5 , tz = `Asia / Calcutta` )

  
# Print DatetimeIndex

print (didx )

Output:

Now we want to find out if the dates contained in this DatetimeIndex are the last day of the month.

# determine if days are the last day of the month.
didx.is_month_ end

Output:

As we can see in the output, the function returned an empty array containing boolean values ​​for each entry in the DatetimeIndex object.  True values ​​indicate that the corresponding date was the last day of the month, and False values ​​indicate that the corresponding date was not the last day of the month.