Complete the code to read a CSV file named 'data.csv' into a DataFrame.
import pandas as pd df = pd.[1]('data.csv')
The read_csv function is used to read CSV files into a pandas 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 a CSV file with a semicolon separator.
import pandas as pd df = pd.read_csv('data.csv', sep=[1])
The sep parameter defines the delimiter used in the CSV file. For semicolon-separated files, use ';'.
Fill both blanks to read 'data.csv' using only columns 'Name' and 'Age'.
import pandas as pd df = pd.read_csv('data.csv', usecols=[1], dtype=[2])
usecols selects columns to load. dtype sets data types for columns.
Fill all three blanks to read 'data.csv' skipping the first row, setting index to 'ID', and parsing dates in 'Date' column.
import pandas as pd df = pd.read_csv('data.csv', skiprows=[1], index_col=[2], parse_dates=[3])
skiprows=1 skips the first row, index_col='ID' sets the index column, and parse_dates=['Date'] parses the 'Date' column as dates.