pandas.read_csv to the rescue:

import pandas as pd
df = pd.read_csv("data.csv")
print(df)

This outputs a pandas DataFrame:

        Date    price  factor_1  factor_2
0  2012-06-11  1600.20     1.255     1.548
1  2012-06-12  1610.02     1.258     1.554
2  2012-06-13  1618.07     1.249     1.552
3  2012-06-14  1624.40     1.253     1.556
4  2012-06-15  1626.15     1.258     1.552
5  2012-06-16  1626.15     1.263     1.558
6  2012-06-17  1626.15     1.264     1.572
Answer from root on Stack Overflow
🌐
Pandas
pandas.pydata.org β€Ί docs β€Ί reference β€Ί api β€Ί pandas.DataFrame.to_csv.html
pandas.DataFrame.to_csv β€” pandas 3.0.4 documentation
For other URLs (e.g. starting with ... to fsspec.open. Please see fsspec and urllib for more details, and for more examples on storage options refer here. ... If path_or_buf is None, returns the resulting csv format as a string. Otherwise returns None. ... Load a CSV file into a DataFrame...
🌐
Pandas
pandas.pydata.org β€Ί docs β€Ί reference β€Ί api β€Ί pandas.read_csv.html
pandas.read_csv β€” pandas 3.0.4 documentation - PyData |
Read a comma-separated values (csv) file into DataFrame. Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the online docs for IO Tools.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί creating-a-dataframe-using-csv-files
Creating a dataframe using CSV files - GeeksforGeeks
July 15, 2025 - read_csv() function is the most commonly used and efficient way to read CSV files into a DataFrame.
🌐
GeeksforGeeks
geeksforgeeks.org β€Ί python β€Ί convert-csv-to-pandas-dataframe
Convert CSV to Pandas Dataframe - GeeksforGeeks
July 23, 2025 - Example 2: Here is another example to convert a CSV dataset into pandas data frame. ... # import pandas module import pandas as pd # making dataframe df = pd.read_csv("nba.csv") # output the dataframe print(df)
Top answer
1 of 4
234

pandas.read_csv to the rescue:

import pandas as pd
df = pd.read_csv("data.csv")
print(df)

This outputs a pandas DataFrame:

        Date    price  factor_1  factor_2
0  2012-06-11  1600.20     1.255     1.548
1  2012-06-12  1610.02     1.258     1.554
2  2012-06-13  1618.07     1.249     1.552
3  2012-06-14  1624.40     1.253     1.556
4  2012-06-15  1626.15     1.258     1.552
5  2012-06-16  1626.15     1.263     1.558
6  2012-06-17  1626.15     1.264     1.572
2 of 4
36

To read a CSV file as a pandas DataFrame, you'll need to use pd.read_csv, which has sep=',' as the default.

But this isn't where the story ends; data exists in many different formats and is stored in different ways so you will often need to pass additional parameters to read_csv to ensure your data is read in properly.

Here's a table listing common scenarios encountered with CSV files along with the appropriate argument you will need to use. You will usually need all or some combination of the arguments below to read in your data.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ pandas Implementation                                 β”‚ Argument              β”‚ Description                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ pd.read_csv(..., sep=';')                             β”‚ sep/delimiter         β”‚ Read CSV with different separatorΒΉ                 β”‚
β”‚ pd.read_csv(..., delim_whitespace=True)               β”‚ delim_whitespace      β”‚ Read CSV with tab/whitespace separator             β”‚
β”‚ pd.read_csv(..., encoding='latin-1')                  β”‚ encoding              β”‚ Fix UnicodeDecodeError while readingΒ²              β”‚
β”‚ pd.read_csv(..., header=False, names=['x', 'y', 'z']) β”‚ header and names      β”‚ Read CSV without headersΒ³                          β”‚
β”‚ pd.read_csv(..., index_col=[0])                       β”‚ index_col             β”‚ Specify which column to set as the index⁴          β”‚
β”‚ pd.read_csv(..., usecols=['x', 'y'])                  β”‚ usecols               β”‚ Read subset of columns                             β”‚
β”‚ pd.read_csv(..., thousands='.', decimal=',')          β”‚ thousands and decimal β”‚ Numeric data is in European format (eg., 1.234,56) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Footnotes

  1. By default, read_csv uses a C parser engine for performance. The C parser can only handle single character separators. If your CSV has a multi-character separator, you will need to modify your code to use the 'python' engine. You can also pass regular expressions:

     df = pd.read_csv(..., sep=r'\s*\|\s*', engine='python')
    
  2. UnicodeDecodeError occurs when the data was stored in one encoding format but read in a different, incompatible one. Most common encoding schemes are 'utf-8' and 'latin-1', your data is likely to fit into one of these.

  3. header=False specifies that the first row in the CSV is a data row rather than a header row, and the names=[...] allows you to specify a list of column names to assign to the DataFrame when it is created.

  4. "Unnamed: 0" occurs when a DataFrame with an un-named index is saved to CSV and then re-read after. Instead of having to fix the issue while reading, you can also fix the issue when writing by using

     df.to_csv(..., index=False)
    

There are other arguments I've not mentioned here, but these are the ones you'll encounter most frequently.

🌐
DataCamp
datacamp.com β€Ί tutorial β€Ί save-as-csv-pandas-dataframe
How to Save a Pandas DataFrame to CSV | DataCamp
June 26, 2024 - Replace 'your_file_name.csv' with the desired name and path for your file. The index=False argument prevents Pandas from adding an index column to your CSV. Now, let’s look at the longer answer. Instead of creating a DataFrame from scratch, I’ll import a dataset, modify it, and save the resulting DataFrame in CSV format.
🌐
Medium
medium.com β€Ί @punya8147_26846 β€Ί exploring-pandas-reading-csv-files-into-dataframes-331e63b33896
Exploring Pandas : Reading CSV Files into DataFrames | by Punyakeerthi BL | Medium
June 23, 2024 - Read data from a CSV file into a DataFrame. Access data points using indexing and selection. Add new columns to a DataFrame.
🌐
PYnative
pynative.com β€Ί home β€Ί python β€Ί pandas β€Ί python pandas read csv into dataframe
Python pandas read CSV into DataFrame
March 9, 2023 - Read different types of CSV files and create a pandas DataFrame. Covers all the customizations that need to apply to transform the CSV file data into the DataFrame.
Find elsewhere
🌐
W3Schools
w3schools.com β€Ί python β€Ί pandas β€Ί pandas_csv.asp
Pandas Read CSV
Download data.csv. or Open data.csv ... Tip: use to_string() to print the entire DataFrame.
🌐
Programiz
programiz.com β€Ί python-programming β€Ί pandas β€Ί csv
Pandas CSV (With Examples)
In Pandas, the read_csv() function allows us to read data from a CSV file into a DataFrame.
🌐
Saturn Cloud
saturncloud.io β€Ί blog β€Ί how-to-convert-csv-file-to-pandas-dataframe
How to Convert CSV File to Pandas DataFrame | Saturn Cloud Blog
May 1, 2026 - In this article, we have explained how to convert a CSV file to a Pandas DataFrame in Python. We have covered the basic steps involved in the process, including importing the Pandas library, reading the CSV file, exploring the data, and saving the DataFrame back to a CSV file.
🌐
Earth Data Science
earthdatascience.org β€Ί home
Import CSV Files Into Pandas Dataframes | Earth Data Science - Earth Lab
September 23, 2019 - Import tabular data from .csv files into pandas dataframes. Recall that scientific data can come in a variety of file formats and types, including comma-separated values files (.csv), which use delimiters such as commas (or some other delimiter like tab spaces or semi-colons) to indicate separate values.
🌐
Note.nkmk.me
note.nkmk.me β€Ί home β€Ί python β€Ί pandas
pandas: Read CSV into DataFrame with read_csv() | note.nkmk.me
August 4, 2023 - In pandas, pandas.read_csv() allows you to read CSV or TSV files into pandas.DataFrame objects.
🌐
DigitalOcean
digitalocean.com β€Ί community β€Ί tutorials β€Ί pandas-to_csv-convert-dataframe-to-csv
Pandas to_csv() - Convert DataFrame to CSV | DigitalOcean
August 3, 2022 - DataFrame: Name ID Role 0 Pankaj 1 NaT 1 Meghna NaT CTO CSV String: ,Name,ID,Role 0,Pankaj,1, 1,Meghna,,CTO CSV String with Null Data Representation: ,Name,ID,Role 0,Pankaj,1,None 1,Meghna,None,CTO Β· Pandas read_csv() – Reading CSV File to DataFrame
🌐
DigitalOcean
digitalocean.com β€Ί community β€Ί tutorials β€Ί r-read-csv-file-into-data-frame
Reading the CSV file into Data frames in R | DigitalOcean
August 3, 2022 - By this process you can read the csv files in R with the use of read.csv(β€œ β€œ) function. This tutorial covers how to import the csv file and reading the csv file and extracting some specific information from the data frame.
🌐
Medium
medium.com β€Ί @smrati.katiyar β€Ί importing-a-csv-file-into-pandas-data-frame-and-explore-it-017c1a61cb72
importing a csv file into pandas data frame and explore it | by smrati katiyar | Medium
October 7, 2024 - Importing a csv file into pandas dataframe Β· import pandas as pd df = pd.read_csv('dummy_data.csv') df.head() Press enter or click to view image in full size Β· On the left side of above image the highlighted column is index column it works as a unique identifier for our data frame Β·
🌐
Pandas
pandas.pydata.org β€Ί pandas-docs β€Ί stable β€Ί reference β€Ί api β€Ί pandas.read_csv.html
pandas.read_csv β€” pandas 2.3.3 documentation - PyData |
Read a comma-separated values (csv) file into DataFrame. Also supports optionally iterating or breaking of the file into chunks. Additional help can be found in the online docs for IO Tools.
🌐
DataCamp
datacamp.com β€Ί tutorial β€Ί pandas-read-csv
pandas read_csv() Tutorial: Importing Data | DataCamp
March 31, 2026 - For data available in a tabular format and stored as a CSV file, you can use pandas to read it into memory using the read_csv() function, which returns a pandas dataframe.