Generation

generate functionTue, 14 Feb 2023

Rewrite the function below so it is called 'is_month_end' instead of 'is_quarter_end' and output 1 if the 'Date' column shows the last day of the month df['is_quarter_end'] = np.where(df['month']%3==0,1,0) df.head()

def is_month_end(date): if date[-2:] == '31': return 1 else: return 0 df['is_month_end'] = df['Date'].apply(is_month_end) df.head()

Questions about programming?Chat with your personal AI assistant