I have dataframe like this
id Date
546451991 2018-07-31 00:00:00
546451991 2018-08-02 00:00:00
5441440119 2018-08-13 00:00:00
5441440119 2018-08-13 00:00:00
5441440119 2018-08-14 00:00:00
5344265358 2018-07-13 00:00:00
5344265358 2018-07-15 00:00:00
5441438884 2018-07-19 00:00:00
I want to groupby 'ID' then sort on the basis of date then add a column containing date of next ROW
E.g i want output like this
id Date Date1
546451991 2018-07-31 00:00:00 2018-08-02 00:00:00
546451991 2018-08-02 00:00:00 NULL
5441440119 2018-08-13 00:00:00 2018-08-14 00:00:00
5441440119 2018-08-14 00:00:00 2018-08-15 00:00:00
5441440119 2018-08-15 00:00:00 NULL
5344265358 2018-07-13 00:00:00 2018-07-15 00:00:00
5344265358 2018-07-15 00:00:00 NULL
5441438884 2018-07-19 00:00:00 NULL
i have tried but not succeeded
df.groupby('id')['Date'].sort_values() not working