Import a CSV file in Jupyter
Updated August 29, 2026
Pandas can load a CSV into a DataFrame:
from pathlib import Path
import pandas as pd
path = Path("data/sales.csv")
df = pd.read_csv(path)
df.head()
The path is relative to the notebook server's current working directory, not necessarily the directory containing the Python source you are thinking of. Check it with:
from pathlib import Path
Path.cwd()
For a file with a different delimiter or encoding, pass explicit options such as sep=";" or encoding="utf-8-sig". Inspect df.columns, df.dtypes, and a few rows before doing calculations. Do not blindly use encoding_errors="ignore", because silently discarded characters can change data.
If pandas is not installed, run %pip install pandas in a notebook cell so the package goes into the kernel environment, then restart the kernel if needed. Keep raw data separate from generated output and avoid embedding personal data in a notebook you plan to share.
Sources
related.
Ruslan Osipov
About the author