Python Language Using pandas


Example

Write a CSV file from a dict or a DataFrame.

import pandas as pd

d = {'a': (1, 101), 'b': (2, 202), 'c': (3, 303)}
pd.DataFrame.from_dict(d, orient="index")
df.to_csv("data.csv")

Read a CSV file as a DataFrame and convert it to a dict:

df = pd.read_csv("data.csv")
d = df.to_dict()