Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dataframe to dictionary without index

df.to_dict(orient='records')
Comment

dataframe to dict without index

df.to_dict('index')
Comment

dataframe to dictionary using index as key

#Use the Dataframe index as the key of the dictionary
df.to_dict('index')
Comment

dataframe to dict without index

df.to_dict('list')
Comment

dataframe to dict without index

{0: {'Name': 'John', 'Age': 38, 'City': 'Boston'},
 1: {'Name': 'Sara', 'Age': 47, 'City': 'Charlotte'},
 2: {'Name': 'Peter', 'Age': 63, 'City': 'London'},
 3: {'Name': 'Cecilia', 'Age': 28, 'City': 'Memphis'}}
Comment

dataframe to dict without index

{'Name': ['John', 'Sara', 'John', 'Sara'],
 'Sem': ['Sem1', 'Sem1', 'Sem2', 'Sem2'],
 'Subject': ['Mathematics', 'Biology', 'Biology', 'Mathematics'],
 'Grade': ['A', 'B', 'A+', 'B++']}
Comment

PREVIOUS NEXT
Code Example
Python :: end python program 
Python :: Using Python Permutations function on a String 
Python :: Get files from S3 bucket Python 
Python :: How to split a text column into two separate columns? 
Python :: convert numpy array to cv2 image 
Python :: python how to replace a certain string in text 
Python :: seaborn boxplot 
Python :: python 3 replace all whitespace characters 
Python :: how to remove items from list in python 
Python :: pandas rename column values dictionary 
Python :: python input timeout 
Python :: add new keys to a dictionary python 
Python :: web scraping python beautifulsoup 
Python :: click ok on alert box selenium webdriver python 
Python :: python recursively print directory 
Python :: make white image numpy 
Python :: python sort list 
Python :: python location 
Python :: Origin in CORS_ORIGIN_WHITELIST is missing scheme or netloc 
Python :: drop list of columns pandas 
Python :: how to convert into grayscale opencv 
Python :: selenium open inspect 
Python :: pdf to csv conversion 
Python :: plot multiple axes matplotlib 
Python :: SystemError: tile cannot extend outside image 
Python :: how to close a flask web server with python 
Python :: how to run .exe from python 
Python :: random search cv 
Python :: calculate mean on python 
Python :: or in django query 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =