Assign the first instance of incremental date from one column to another column in pandas data frame

26 Views Asked by At

If the date in a column starts to be incremental, then assign that date to a new column in pandas. Below is how my dataframe looks like.

The column MeasureDate_day has the date incremental from line 3 till line 5. For this type of instance I want the date 2022-12-03 (from line 3) to be assigned into a new column against line 5. For every two instances if the date is incremental, the third row should be assigned the first instance of the incremental date in a new column.

I'm confused how to do it.

enter image description here

Below is what i'm expecting as output

enter image description here

I have tried using groupby, value_counts, apply lambda etc, but nothing gave me the result that I'm looking for.

0

There are 0 best solutions below