I have a Python dictionary like the following:
{u\'2012-06-08\': 388,
u\'2012-06-09\': 388,
u\'2012-06-10\': 388,
u\'2012-06-11\': 389,
u\'2012-06-12\':
d = {'Date': list(yourDict.keys()),'Date_Values': list(yourDict.values())}
df = pandas.DataFrame(data=d)
If you don't encapsulate yourDict.keys()
inside of list()
, then you will end up with all of your keys and values being placed in every row of every column. Like this:
Date \
0 (2012-06-08, 2012-06-09, 2012-06-10, 2012-06-1...
1 (2012-06-08, 2012-06-09, 2012-06-10, 2012-06-1...
2 (2012-06-08, 2012-06-09, 2012-06-10, 2012-06-1...
3 (2012-06-08, 2012-06-09, 2012-06-10, 2012-06-1...
4 (2012-06-08, 2012-06-09, 2012-06-10, 2012-06-1...
But by adding list()
then the result looks like this:
Date Date_Values
0 2012-06-08 388
1 2012-06-09 388
2 2012-06-10 388
3 2012-06-11 389
4 2012-06-12 389
...