Question bank

Pick an answer to see if you're right — with an explanation.

PandasEasy
Which method shows the first 5 rows?
adf.first()
bdf.top()
cdf.show()
ddf.head()
PandasEasy
Which argument makes `pd.read_csv` interpret 05/04/2025 as 5 April 2025?
amonthfirst=False
bdayfirst=True
cformat='US'
dparse_dates=False
PandasEasy
Select rows by label with…
aloc
biloc
cat
dix
PandasEasy
What does `pd.read_excel('file.xlsx', sheet_name=None)` return?
aOnly the first sheet
bA list of column names
cA dict mapping sheet names to DataFrames
dThe number of sheets
PandasEasy
How do you count missing values per column?
adf.count_na()
bdf.missing()
cdf.isna().sum()
ddf.null()
PandasEasy
Which method converts a wide table (one column per month) into long format?
amelt
bpivot
cunstack
dexplode
PandasMedium
Which merges two DataFrames on a key?
adf.join_on()
bdf.merge()
cpd.concat()
ddf.combine()
PandasEasy
Which dtype is best for a column with only 5 distinct payment modes repeated across millions of rows?
aobject
bfloat64
cstring
dcategory
PandasMedium
What does `df.groupby('city')['sales'].sum()` return?
aA Series indexed by city
bA DataFrame
cA list
dA dict
PandasMedium
What does this code return?
s = df.set_index("date")["amount"]
s.resample("ME").sum()
aTotal amount for each calendar month, labelled by month end
bThe mean amount per week
cThe row with the largest amount
dA TypeError because ME is invalid
PandasEasy
Which attribute gives the number of rows and columns as a tuple?
adf.size
bdf.shape
cdf.length
ddf.count()
PandasMedium
`df.pivot(index='branch', columns='month', values='sales')` raises `ValueError: Index contains duplicate entries`. What is the fix?
aUse df.melt instead
bUse pd.pivot_table with an aggfunc such as 'sum'
cSort the DataFrame first
dConvert month to category
PandasMedium
What does `top` contain?
top = df.sort_values('sales', ascending=False).head(3)
aThe 3 rows with the smallest sales
bThe first 3 rows of the original order
cThe 3 rows with the largest sales
dA Series of 3 sales values
PandasMedium
Why does `df.to_csv('out.csv')` often produce an `Unnamed: 0` column when read back?
aCSV cannot store integers
bThe encoding is wrong
cThe index was written as a column; use index=False
dpandas adds a checksum column
PandasMedium
By default, which columns does `df.describe()` summarise?
aEvery column
bOnly object columns
cOnly the index
dOnly the numeric columns