Which of the following will help us to read the content of a CSV file…

2023

Which of the following will help us to read the content of a CSV file ITEMS.CSV as pandas DataFrame ?

  1. A.

    IT=pandas.read("ITEMS.CSV")

  2. B.

    IT=pandas.readcsv("ITEMS.CSV")

  3. C.

    IT=pandas.csv_read("ITEMS.CSV")

  4. D.

    IT=pandas.read_csv("ITEMS.CSV")

Attempted by 1297 students.

Show answer & explanation

Correct answer: D

Correct method: Use pandas.read_csv to read a CSV file into a DataFrame.

Example usage:

  • Import pandas (commonly aliased as pd) and call read_csv: import pandas as pd

  • Read the file into a DataFrame: df = pd.read_csv("ITEMS.CSV")

Common mistakes to avoid:

  • Using pandas.read (no read function for CSV) or pandas.readcsv (missing underscore).

  • Using pandas.csv_read (incorrect function name) or inserting a space like pandas.read _csv (remove the space).

  • If the file uses a different delimiter, pass the sep argument, for example pd.read_csv("ITEMS.CSV", sep=';').

Therefore, the correct call is pandas.read_csv("ITEMS.CSV") (typically used as pd.read_csv("ITEMS.CSV")).

Explore the full course: Bpsc