Reputation: 12509
I have a dictionary that looks like this:
{'ny': [84L, 27], 'life': [9L, 18], 'uk': [4L, 3], 'la': [18L, 6]}
I tried turning it into data frame like this:
df = pd.DataFrame(active_posts.items())
and I got this:
0 1
0 ny [769, 40]
1 life [579, 37]
2 au [180, 9]
3 uk [309, 17]
4 la [454, 20]
But I would each index of the list to have it's own column, instead of one column containing the whole list. Is this easily possible with pandas, or would formatting the original dictionary differently be easier? If so, how would you format the original dict?
Upvotes: 0
Views: 48
Reputation: 251355
Just pass the dict itself as the argument:
>>> pandas.DataFrame(active_posts)
la life ny uk
0 18 9 84 4
1 6 18 27 3
Upvotes: 2