I have a dataframe with offer data that I want to transform into portion data. The column quantity tells how many portions each offer has. If an offer has three portions out of which two were sold, that row should appear three times in the new dataframe, so that the sold column has value 1 on two rows and value 0 on one row.
The actual dataframe contains more columns that should stay intact in the transformed dataframe. Date column works as an example.
My input:
Offer name Quantity Sold Date
0 A 3 2 2022-05
1 B 2 1 2022-01
2 C 1 1 2022-04
3 D 1 1 2022-04
4 E 1 1 2022-05
The desired output:
Offer name Quantity Sold Date
0 A 1 1 2022-05
1 A 1 1 2022-05
2 A 1 0 2022-05
3 B 1 1 2022-01
4 B 1 0 2022-01
and so on...
Thank you!!
Soldis greater thanQuantity?