Pixelomo
0
Q:

pandas dataframe from dict

data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
pd.DataFrame.from_dict(data)
7
>>> data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
>>> pd.DataFrame.from_dict(data)
   col_1 col_2
0      3     a
1      2     b
2      1     c
3      0     d
1
>>> pd.DataFrame.from_dict(data, orient='index',
...                        columns=['A', 'B', 'C', 'D'])
       A  B  C  D
row_1  3  2  1  0
row_2  a  b  c  d
1
>>> data = {'row_1': [3, 2, 1, 0], 'row_2': ['a', 'b', 'c', 'd']}
>>> pd.DataFrame.from_dict(data, orient='index')
       0  1  2  3
row_1  3  2  1  0
row_2  a  b  c  d
1
pd.DataFrame.from_dict(data)
0
import pandas as pd 
  
  
data = [{'area': 'new-hills', 'rainfall': 100, 'temperature': 20}, 
         {'area': 'cape-town',  'rainfall': 70, 'temperature': 25}, 
         {'area': 'mumbai',  'rainfall': 200,  'temperature': 39 }] 
  
df = pd.DataFrame.from_dict(data) 
  
df 
0

New to Communities?

Join the community