I have a dataframe
rr = pd.DataFrame([['A', pd.to_datetime('2010-01-01'), 12],
['A', pd.to_datetime('2010-01-01'), 6],
['A', pd.to_datetime('2010-03-01'), 3]], columns = ['id','date', 'variable'])
sucht that rr :
id date variable
0 A 2010-01-01 12
1 A 2010-01-01 6
2 A 2010-03-01 3
I would like to have:
id date date_lead variable
0 A 2010-01-01 2010-02-01 1
1 A 2010-02-01 2010-03-01 12
2 A 2010-02-01 2010-03-01 6
3 A 2010-03-01 NaT 3
A normal shift operation will not suffice. How do I achieve this