Let's say I have the following dataframe:
ID list
1 [543,4]
2 [1,2]
3 [3,4]
4 [7,8]
5 [9,10,11]
Where ID is an int and 'list' is a column that has a list in each value. What would be an efficient way of creating another dataframe from this one where the list is flattened into a column where each row is a value in the list repeating the ID value for the length of each list.
The following is the desired output:
ID Value
1 543
1 4
2 1
2 2
3 3
3 4
4 7
4 8
5 9
5 10
5 11
One limitation, my company is still using Python 2.7 unfortunately....