Recall & Review
beginner
What is a common cause of dtype errors when reading CSV files in pandas?
A common cause is that pandas guesses the wrong data type for columns, especially when columns have mixed types or missing values.
Click to reveal answer
beginner
How can you convert a pandas column to numeric type safely?
Use
pd.to_numeric() with errors='coerce' to convert values to numbers and turn invalid parsing into NaN.Click to reveal answer
beginner
What does the error 'cannot convert string to float' usually mean in pandas?
It means pandas tried to convert a column with non-numeric strings to float but failed because some values are not numbers.
Click to reveal answer
intermediate
How do you fix dtype errors caused by missing values in integer columns?
Convert the column to a nullable integer type like
Int64 instead of int64 to allow NaN values.Click to reveal answer
beginner
What pandas method helps to convert columns to datetime and handle errors?
Use
pd.to_datetime() with errors='coerce' to convert columns to datetime and set invalid parsing to NaT.Click to reveal answer
Which pandas function converts a column to numeric and replaces invalid parsing with NaN?
✗ Incorrect
The correct function is pd.to_numeric() with errors='coerce' to safely convert values.
What dtype should you use for integer columns that have missing values?
✗ Incorrect
The nullable integer type Int64 supports missing values (NaN) unlike int64.
If pandas raises 'cannot convert string to float', what is likely the problem?
✗ Incorrect
Non-numeric strings cannot be converted to float, causing this error.
Which method converts a column to datetime and sets invalid dates to NaT?
✗ Incorrect
pd.to_datetime() with errors='coerce' converts dates and sets invalid ones to NaT.
What is a quick way to check the data types of all columns in a pandas DataFrame?
✗ Incorrect
df.dtypes shows the data type of each column in the DataFrame.
Explain common dtype errors in pandas and how to fix them when reading data.
Think about how pandas guesses types and what to do when it guesses wrong.
You got /6 concepts.
Describe how to handle non-numeric strings in numeric columns in pandas.
Focus on safe conversion methods and handling invalid data.
You got /4 concepts.