Say I have a dataframe like this:
data = {'state':['FL', 'FL', 'FL'],
'territory':[1, 2, 3],
'proportion':['A-0.7/B-0.3', 'A-0.7/B-0.3', 'A-0.7/B-0.3'],
'value':[10, 10, 10]}
df = pd.DataFrame(data)
state territory proportion value
0 FL 1 A-0.7/B-0.3 10
1 FL 2 A-0.7/B-0.3 10
2 FL 3 A-0.7/B-0.3 10
For each row, I want to split the 'value' into two rows based on the 'proportion'
data = {'state':['FL', 'FL', 'FL', 'FL', 'FL', 'FL'],
'territory':[1, 1, 2, 2, 3, 3],
'proportion':['A', 'B', 'A', 'B', 'A', 'B'],
'value':[7, 3, 7, 3, 7, 3,]}
pd.DataFrame(data)
state territory proportion value
0 FL 1 A 7
1 FL 1 B 3
2 FL 2 A 7
3 FL 2 B 3
4 FL 3 A 7
5 FL 3 B 3
How do I do this?