pandas skill check
Practise pandas: selection with loc and iloc, groupby, merges, missing data, reshaping, and dates, including snippets where you predict the resulting frame.
15
Questions
11 min
Timer can't pause
Multiple choice
pandas 2
Choose a level
Topics
- Series and DataFrames
- Indexing and selection
- groupby
- Merging and joining
- Missing data
- Reshaping
- Dates
- Performance
Do
Use scratch paper or a notepad to work things out. Skip a question and come back to it later.
Don't
Look up answers during the check. Open the check in more than one tab or window.
Easy · 15 questions · 11 min
By starting, you agree to the Terms and Privacy Policy.
Practice checks each answer as you go, with an explanation. The exam is checked when you submit; 9 of 15 passes and earns a certificate.
Checking your levels…
Certificates come from the certified exam: pass with 9 of 15 while signed in. View a sample certificate.
Sample pandas questions with answers
These are never used in a check, so seeing their answers here won't give anything away.
Question 1 · Easy · Indexing and selection
In pandas, what is the fundamental behavioral difference between slicing with.loc[]and slicing with.iloc[]when using labels versus positions?- A.
.loc[]includes the stop endpoint, while.iloc[]excludes the stop endpoint. - B.Both
.loc[]and.iloc[]exclude the stop endpoint by default. - C.Both
.loc[]and.iloc[]include the stop endpoint when numeric ranges are used. - D.
.loc[]excludes the stop endpoint, while.iloc[]includes the stop endpoint.
Show answer
A.
.loc[]includes the stop endpoint, while.iloc[]excludes the stop endpoint..loc[]is label-based indexing and includes both the start and stop boundaries in slice operations. In contrast,.iloc[]is integer-position based and follows Python's standard zero-indexed slicing where the stop position is excluded.- A.
Question 2 · Easy · Series and DataFrames
What is the return type when selecting a single column from a DataFrame using single-bracket syntax, such asdf['col'], versus double-bracket syntax, such asdf[['col']]?- A.
df['col']returns a 1D NumPy ndarray, whereasdf[['col']]returns a pandas Series. - B.
df['col']returns a pandas Series, whereasdf[['col']]returns a single-column DataFrame. - C.
df['col']returns a single-column DataFrame, whereasdf[['col']]returns a pandas Series. - D.Both expressions return a pandas Series with identical metadata and dimensions.
Show answer
B.
df['col']returns a pandas Series, whereasdf[['col']]returns a single-column DataFrame.Single brackets extract the column as a 1D pandas Series object. Passing a list of column names inside brackets (even with only one element) preserves DataFrame dimensionality and returns a DataFrame.- A.
Question 3 · Moderate · Missing data
In pandas 2.x, how does the behavior of nullable integer types (such asInt64) differ from traditional NumPy-backed integer types (int64) when encountering missing values?- A.
Int64raises aValueErrorwhenever null values are encountered during assignment, whereasint64allows them. - B.
Int64usesNoneas a sentinel value, whereasint64usespd.NA. - C.
Int64supportspd.NAwithout typecasting, whereasint64is coerced tofloat64to storenp.nan. - D.
Int64replaces missing values with 0 automatically, whereasint64leavesnp.nan.
Show answer
C.
Int64supportspd.NAwithout typecasting, whereasint64is coerced tofloat64to storenp.nan.Standard NumPy integer arrays cannot represent missing values, so pandas historically upcastedint64tofloat64to holdnp.nan. The nullable integer extension typeInt64uses a separate boolean mask to track missing values aspd.NAwithout changing the underlying integer dtype.- A.
Question 4 · Advanced · groupby
Consider grouping a DataFrame by a column containing missing values using df.groupby('key'). Which statement accurately describes the default behavior of groupby regarding missing keys and how to preserve them?- A.Missing keys are grouped into an empty index slice and can only be recovered using the as_index=False parameter.
- B.Missing keys are included in aggregations by default and placed in a group labeled NaN unless dropna=True is specified.
- C.Missing keys are excluded from groups by default; passing dropna=False to groupby retains them as a distinct group across aggregations.
- D.Missing keys raise a KeyError during aggregation unless fillna() is called prior to invoking groupby.
Show answer
C. Missing keys are excluded from groups by default; passing dropna=False to groupby retains them as a distinct group across aggregations.
By default, pandas groupby sets dropna=True, which excludes NA values from the group keys. Setting dropna=False includes NA values as a separate group in the result.
How scoring and certificates work
- Each check has 15 multiple-choice questions with one correct answer, and one timer for the whole check. A question you leave unanswered scores nothing.
- Practice is free without an account and shows whether each answer is right as you go, with an explanation.
- The certified exam is scored when you submit. 60% passes, which is 9 of 15. Easy unlocks Moderate, and Moderate unlocks Advanced.
- Passing the exam while signed in earns a free certificate, valid for one year, with its own verification page. See a sample certificate.
Free tools for pandas: CSV to JSON, JSON to CSV, JSON Statistics