2017-10-04 77 views

回答

1

用途:

df['NextDestination'] = df.groupby('UserId')['Destination'].shift(-1) 
print (df) 
    UserId Destination NextDestination 
0  1   A    B 
1  1   B    C 
2  1   C    NaN 
3  2   D    E 
4  2   E    NaN