NEW
Font size
WorksheetsLong Quiz | Data Preparation
Total questions: 30
Worksheet time: 15mins
If a dataset has 100 rows, and after running df.dropna(how="all") there are 90 rows left, how many empty rows were deleted?
a. 5
b. 10
c. 15
d. 20
Which pandas function is used to remove rows that are completely empty?
df.dropna(how="any")
df.drop_duplicates()
df.dropna(how="all")
df.fillna(0)
What does df.drop_duplicates() do?
Fills missing values with zero
Removes duplicate rows
Removes all empty rows
Splits text into multiple columns
The parameter errors="coerce" in pd.to_numeric() means:
Replace invalid entries with NaN
Skip conversion if error happens
Raise an error if a non-numeric is found
Convert numbers into strings
In pandas, text data is usually stored as what dtype by default?
int64
float64
string[python]
object
The command df.dropna(how="all") removes only the rows where every column is empty.
True
False
df.drop_duplicates() will delete only empty rows, not duplicate rows.
True
False
The command df["Notes"].str.split(",", expand=True) splits the Notes column into multiple columns whenever a comma is found.
True
False
The function len(df) counts how many columns the dataset has.
True
False
If you write only df in a Jupyter cell, it will display the entire dataset.
True
False
Which command removes duplicate rows across the whole dataset?
df.dropna()
df.drop_duplicates()
df.remove_duplicates()
df.delete_duplicates()
Which argument lets you remove duplicates from a specific column only?
subset=["Student_ID"]
column=["Student_ID"]
unique=["Student_ID"]
id=["Student_ID"]
By default, when using drop_duplicates(), pandas keeps:
All duplicates
The last occurrence of the duplicate
The first occurrence of the duplicate
None of the rows
Which command shows only the first 10 rows of the DataFrame?
df.head(10)
df.show(10)
df.print(10)
df.display(10)
What does the command len(df) return?
The number of rows
The number of columns
The number of duplicates
The total file size
Which string-building code correctly shows the results of duplicate removal?
"Removed: " + removed
"Removed: ", removed
removed + "Removed"
"Removed: " + str(removed)
Why is removing duplicates important in data preparation?
To make the dataset smaller in file size
To remove all missing values
To make the dataset easier to save in Excel
To avoid repeated values that can affect analysis
After removing duplicates, which code correctly counts the new number of rows?
df.count()
df.shape[1]
len(df)
df.size
The command df.to_excel("file.xlsx", index=False) is used to save the cleaned dataset into a new Excel file.
True
False
We can find duplicates in a specific column using the subset parameter.
True
False
What does .str.strip() do in the command df["Department"].astype(str).str.strip()?
Removes spaces before and after text
Removes all vowels in the text
Changes text to lowercase
Replaces missing values with NaN
Which command shows all unique values of the Department column?
df["Department"].all()
df["Department"].nunique()
df["Department"].unique()
df["Department"].value_counts()
Which of the following best describes "data inconsistency"?
Duplicate rows in a dataset
Empty rows with no values
Incorrect or misspelled entries in the data
Columns with mixed data types
df["Department"].astype(str).str.strip() will automatically correct wrong spellings like “Accguntancy” to “Accountancy.”
True
False
Using .unique() on a column helps in spotting inconsistent spellings of department names.
True
False
Which line correctly changes GPA to float numbers?
df["GPA"] = df["GPA"].astype("float64")
df["GPA"] = df["GPA"].astype("int64")
df["GPA"] = df["GPA"].astype("string")
df["GPA"] = df["GPA"].astype("object")
The command df.dtypes shows the current data types of all columns.
True
False
The default dtype for text columns in pandas is string.
True
False
Splitting a text column into multiple columns is an example of data preparation.
True
False
Data type conversion is unnecessary if the dataset loads without errors.
True
False
