Complete the code to read the CSV file 'data.csv' into a DataFrame named df.
import pandas as pd df = pd.[1]('data.csv')
The read_csv function from pandas is used to read CSV files into a DataFrame.
Complete the code to read 'data.csv' but only load the first 5 rows.
import pandas as pd df = pd.read_csv('data.csv', [1]=5)
The nrows parameter limits the number of rows read from the CSV file.
Fix the error in the code to read 'data.csv' with a semicolon separator.
import pandas as pd df = pd.read_csv('data.csv', sep=[1])
The sep parameter specifies the delimiter. For semicolon-separated files, use ';'.
Fill both blanks to read 'data.csv' skipping the first row and using tab as separator.
import pandas as pd df = pd.read_csv('data.csv', skiprows=[1], sep=[2])
To skip the first row, use skiprows=1. For tab separator, use sep='\t'.
Fill both blanks to read 'data.csv' with no header, assign column names, and use comma separator.
import pandas as pd cols = ['Name', 'Age', 'City'] df = pd.read_csv('data.csv', header=[1], names=[2], sep=,)
Use header=None to indicate no header row. Assign column names with names=cols. Use comma as separator with sep=','.