There is a df Pandas dataframe: Date Open High Low Close Adj Close Volume 0 2022-02-14 133.365494 136.166504 133.302002 135.300003 135.300003 26792000 1 2022-02-15 137.471497 137.899994 135.539505 136.425507 136.425507 26578000 2 2022-02-16 136.430496 137.945999 134.823654 137.487503 137.487503 25610000 3 2022-02-17 136.149994 136.839493 132.201996 132.308502 132.308502 30968000 Write a function that creates an is_month_end column and calculates values there as follows: 1) if the 'Date' column contains the last day of the month, the 'is_month_end' column will contain number 1 2) otherwise 0 is written
def is_month_end(date): if date[-2:] == '31': return 1 else: return 0 is_month_end(df['Date'])