I have a dataframe like this one:
df = pd.DataFrame(data={
'date': ['2021-01-01', '2021-01-02','2021-01-03','2021-01-04'],
'order': [False, False, True, True]
})
And I want to have a new column with the shifted date from the column with the next order = True. So the dataframe would look like this:
df_new = pd.DataFrame(data={
'date': ['2021-01-01', '2021-01-02','2021-01-03','2021-01-04'],
'order': [False, False, True, True],
'shifted_date': ['2021-01-03','2021-01-03','2021-01-04',np.nan]
})