Which of the following function is used to read from a 'csv' file into a pandas ('pd' as alias) DataFrame?
Which of the following function is used to read from a 'csv' file into a pandas ('pd' as alias) DataFrame?
Solution
✅ Correct Option: 3
pd.read_csv() reads a CSV file and returns a pandas DataFrame. For example, df = pd.read_csv("data.csv") loads the file into df.
Option 4: to_csv() does the opposite job. It is a DataFrame method that writes data out to a CSV file, as in df.to_csv("out.csv").
Options 1 and 2: load_csv() and write_csv() do not exist in pandas.
The pandas pattern is read_xxx() to import, as in read_excel() and read_json(), and to_xxx() to export.
Related questions:
2025: 14 May Shift 1
2025: 13 May Shift 2
2026: 26 May Shift 1
2026: 13 May Shift 2