Skip to content

Pandas

CSV Files

Read CSV Files

import pandas as pd

df = pd.read_csv('data.csv')
print(df)

Write CSV Files

import pandas as pd

df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 26, 27]})
df.to_csv('data.csv', index=False)

Printing Data

Show a table in the terminal

import pandas as pd

data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 26, 27]}
df = pd.DataFrame(data)
print(df)