I have a dataframe that looks like this
import pandas as pd
import numpy as np
# Create data set.
dataSet = {'id': ['A', 'A', 'B'],
'id_2': [1, 2, 1] ,
'number': [320, 169, 120],
'add_number' : [4,6,3]}
# Create dataframe with data set and named columns.
df = pd.DataFrame(dataSet, columns= ['id', 'id_2','number', 'add_number'])
id id_2 number add_number
0 A 1 320 4
1 A 2 169 6
2 B 1 120 3
I would like use number and add_number so that I can explode this dynamically, ie) 320 + 4 would have [320,321,322,323,324] (up to 324, and would like to explode on this)
DESIRED OUTPUT
id id_2 number
0 A 1 320
1 A 1 321
2 A 1 322
3 A 1 323
4 A 1 324
5 A 2 169
6 A 2 170
7 A 2 171
8 A 2 172
9 A 2 173
10 A 2 174
11 A 2 175
12 B 1 120
13 B 1 121
14 B 1 122
15 B 1 123
I looked over explode, wide_to_long pandas function, but I do not know where to start, any sense of direction would be appreciated!!