Currently I am cutting my data in what I assume is an inefficient manner. I want to know if it is possible to use conditional formatting via a datetime without creating and dropping a column.
I can solve my problem, but currently I am using
input_df['YEAR'] = pd.DatetimeIndex(input_df["TERMSTARTDATE_FORMATTED"]).year
then
recent_df = input_df.drop(input_df[input_df.YEAR < 2018].index)
This works but I can see that it's not elegant. I think there should be a way to just drop the columns from the dataframe without first creating a new column.
Is there a more elegant solution to my problem? What is the pythonic way of dealing with this?