Converting one to many mapping dictionary to Dataframe

Viewed 314

I have a dictionary as follows:

d={1:(array[2,3]), 2:(array[8,4,5]), 3:(array[6,7,8,9])}

As depicted, here the values for each key are variable length arrays.

Now I want to convert it to DataFrame. So the output looks like:

A   B
1   2
1   3
2   8
2   4
2   5
3   6
3   7
3   8
3   9

I used pd.Dataframe(d), but it does not handle one to many mapping.Any help would be appreciated.

3 Answers
Related