This is the my dataset and I am trying to fill the date columns that have NaN with min value.
I am trying to fill the NaN in the date columns with the min from that date column for the ag_id (grouped-by element). When I do the below I get unexpected output.
df_test_revenue_1["1st_rev_month"] = df_test_revenue_1.groupby("ag_id").transform(lambda x: x.fillna(x.min()))
Unexpected output from executing the above :
I was expecting all the values of the column 1st_rev_month
to be 2017-10-01
. Instead it looks like it it picking the values for 1st_rev_month
from column revenue_month
My end goal is to get this result (apple the same logic to rest of the date columns (except revenue_month
column