Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas read dictionary

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
Comment

from pandas to dictionary

df = pd.DataFrame({'col1': [1, 2],
...                    'col2': [0.5, 0.75]},
...                   index=['row1', 'row2'])
>>> df
      col1  col2
row1     1  0.50
row2     2  0.75
>>> df.to_dict()
{'col1': {'row1': 1, 'row2': 2}, 'col2': {'row1': 0.5, 'row2': 0.75}}
Comment

PREVIOUS NEXT
Code Example
Python :: calculate age python 
Python :: extend tuple python 
Python :: corr pandas 
Python :: hello world in python 
Python :: csv library python convert dict to csv 
Python :: remove extra spaces python 
Python :: mediafileupload python example 
Python :: how to open an image in opencv 
Python :: python remove spaces 
Python :: Set a random seed 
Python :: python program to convert unit 
Python :: exec: "python": executable file not found in $PATH Error compiling for board ESP32 Dev Module. 
Python :: how can item in list change in int in python 
Python :: pyspark left join 
Python :: how to find unique values in a column in pandas 
Python :: python convert string to sentence case 
Python :: print alphabets in python 
Python :: clamp number in python 
Python :: how to make a venv python 
Python :: python remove special characters from list 
Python :: tkinter prevent window resize 
Python :: convert list into integer in python 
Python :: make screen shot of specific part of screen python 
Python :: python split list into n sublists 
Python :: print in binary python 
Python :: test split 
Python :: how to insert item last in list python 
Python :: tkinter slider 
Python :: from array to tuple python 
Python :: migrate data django 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =