Answers for "convert pandas dataframe into dictionary"

1

create pandas dataframe from dictionary

In [11]: pd.DataFrame(d.items())  # or list(d.items()) in python 3
Out[11]:
             0    1
0   2012-07-02  392
1   2012-07-06  392
2   2012-06-29  391
3   2012-06-28  391
...

In [12]: pd.DataFrame(d.items(), columns=['Date', 'DateValue'])
Out[12]:
          Date  DateValue
0   2012-07-02        392
1   2012-07-06        392
2   2012-06-29        391
Posted by: Guest on May-01-2021
0

dataframe to dict without index

df.to_dict('index')
Posted by: Guest on May-31-2020
0

pandas to dictionary

df.to_dict('records')
Posted by: Guest on August-06-2020

Code answers related to "convert pandas dataframe into dictionary"

Python Answers by Framework

Browse Popular Code Answers by Language