I feel like there is a better way than this:
import pandas as pd df = pd.DataFrame( [[\'A\', \'X\', 3], [\'A\', \'X\', 5], [\'A\', \'Y\', 7], [\'A\', \'Y
This might be useful
df = df.sort_values(['userID', 'date']) grp = df.groupby('userID')['ItemID'].aggregate(lambda x: '->'.join(tuple(x))).reset_index() print(grp)
it will create a sequence like this