Given table as below
Destination Capacity TruckNum
0 dest1 1 1
1 dest2 1 2
2 dest3 2 2
3 dest4 2 2
From code
df=pd.DataFrame({"Destination":["dest1","dest2","dest3","dest4"], "Capacity":[1,1,2,2], "TruckNum":[1,2,2,2]})
I hope to duplicate row according to TruckNum, that is the desired outcome is:
Destination Capacity
0 dest1 1
1 dest2 1
2 dest2 1
3 dest3 2
4 dest3 2
5 dest4 2
6 dest4 2
Is there an easy way to achieve that?