I have a dataframe of transactions. Each row represents a transaction of two item (think of it like a transaction of 2 event tickets or something). I want to duplicate each
Answer by using repeat
repeat
df.loc[df.index.repeat(df.Quantity)] Out[448]: Price City Quantity 1 20 NYC 2 1 20 NYC 2 2 30 NYC 2 2 30 NYC 2 3 5 NYC 2 3 5 NYC 2 4 300 LA 2 4 300 LA 2 5 30 LA 2 5 30 LA 2 6 100 LA 2 6 100 LA 2