Run Apriori algorithm in python 2.7
df.groupby('device_id')['category'].apply(list).tolist()


There's your transactions LOL.

If you aren't limited to Python 2.7, I'd suggest Orange3-Associate which contains a frequent_itemsets() function based on FP-growth algorithm, which is orders of magnitude faster than Apriori.