Create new rows based on a value in a column
My dateset is generated like the example
df = {'event':['A','B','C','D'],
'budget':['123','433','1000','1299'],
'duration_days':['6','3','4','2']}
I need to create rows for each event based on the column 'duration_days', if I have duration = 6 the event may have 6 rows:
event | budget | duration_days |
---|---|---|
A | 123 | 6 |
A | 123 | 6 |
A | 123 | 6 |
A | 123 | 6 |
A | 123 | 6 |
A | 123 | 6 |
B | 123 | 3 |
B | 123 | 3 |
B | 123 | 3 |
Topic data-science-model dataframe python-3.x pandas dataset
Category Data Science