Skip to content
LearnPY
pandasfunction reference

pd.read_csv

Load a comma-separated file into a DataFrame.

Signature

pd.read_csv(filepath_or_buffer, sep=',', header='infer')

What it does

read_csv parses a delimited text file and infers column names and dtypes. It accepts local paths, URLs, and file-like objects. Arguments such as usecols, dtype, and parse_dates let you control the import.

Parameters

filepath_or_bufferstr, path, or file-like
The CSV source to read.
sepstr, optionaloptional
Field delimiter. Defaults to a comma.
headerint or None, optionaloptional
Row number to use as column names.

Returns

DataFrame

Example

pythonpd.read_csv example
import pandas as pd

df = pd.read_csv("scores.csv")
print(df.head())

Watch out for

  • Leading spaces in column names create labels you cannot select with a plain name.
  • Dates often arrive as strings; pass parse_dates when you need datetime operations.