Pandas rounding up to next year if above a certain date
I seem to have found an answer to my own question. If I'm not mistaken the following should work with all dates:
df['Year'] = np.where(df['Year'].dt.month < 10, df['Year'].dt.year, df['Year'].dt.year + 1)
I am trying to create rules for rounding a datetime column. So far I can only find how to round either to the current year or round up to the next year using df['Year'] = df['Year] + pd.offsets.YearBegin(0) to round up, and df['Year'] = df['Year] + pd.offsets.YearBegin(-1) to round to current year.
However, I am trying to round as follows:
If df['Year'] is in the last quarter of the year (> Sep 30th), then round up to next year, otherwise leave as current year.