Created
September 28, 2020 04:04
-
-
Save coderinboots/ddd03f4d71058299c011e703278988bc to your computer and use it in GitHub Desktop.
Python program to convert a pandas dataframe into list of dictionaries. For more details, visit https://www.coderinboots.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
file_path = "data.csv" | |
delimiter = "," | |
required_fields = ["name", "emp_id"] | |
df = pd.read_csv(file_path, sep=delimiter, usecols=required_fields) | |
data_list = df.to_dict('records') | |
print("Record Count --->", len(data_list)) | |
print(data_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment