Skip to content
Advertisement

CSV data to Python dictionary

I wrote my data which was in lists and dicts to a csv file, and when i import the csv file using pd.read_csv('file.csv'), everything becomes strings. How can i keep or convert it to its original format?

Originally, everything was in a dataframe and then written to a CSV file using df.to_csv(r'./file.csv').

JavaScript

all the rows are strings.

Advertisement

Answer

This will read the column as dicts:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement