Skip to content
codinganthem

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.

Start practice

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.

  1. 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?
    1. A..loc[] includes the stop endpoint, while .iloc[] excludes the stop endpoint.
    2. B.Both .loc[] and .iloc[] exclude the stop endpoint by default.
    3. C.Both .loc[] and .iloc[] include the stop endpoint when numeric ranges are used.
    4. 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.
  2. Question 2 · Easy · Series and DataFrames

    What is the return type when selecting a single column from a DataFrame using single-bracket syntax, such as df['col'], versus double-bracket syntax, such as df[['col']]?
    1. A.df['col'] returns a 1D NumPy ndarray, whereas df[['col']] returns a pandas Series.
    2. B.df['col'] returns a pandas Series, whereas df[['col']] returns a single-column DataFrame.
    3. C.df['col'] returns a single-column DataFrame, whereas df[['col']] returns a pandas Series.
    4. D.Both expressions return a pandas Series with identical metadata and dimensions.
    Show answer

    B. df['col'] returns a pandas Series, whereas df[['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.
  3. Question 3 · Moderate · Missing data

    In pandas 2.x, how does the behavior of nullable integer types (such as Int64) differ from traditional NumPy-backed integer types (int64) when encountering missing values?
    1. A.Int64 raises a ValueError whenever null values are encountered during assignment, whereas int64 allows them.
    2. B.Int64 uses None as a sentinel value, whereas int64 uses pd.NA.
    3. C.Int64 supports pd.NA without typecasting, whereas int64 is coerced to float64 to store np.nan.
    4. D.Int64 replaces missing values with 0 automatically, whereas int64 leaves np.nan.
    Show answer

    C. Int64 supports pd.NA without typecasting, whereas int64 is coerced to float64 to store np.nan.

    Standard NumPy integer arrays cannot represent missing values, so pandas historically upcasted int64 to float64 to hold np.nan. The nullable integer extension type Int64 uses a separate boolean mask to track missing values as pd.NA without changing the underlying integer dtype.
  4. 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?
    1. A.Missing keys are grouped into an empty index slice and can only be recovered using the as_index=False parameter.
    2. B.Missing keys are included in aggregations by default and placed in a group labeled NaN unless dropna=True is specified.
    3. C.Missing keys are excluded from groups by default; passing dropna=False to groupby retains them as a distinct group across aggregations.
    4. 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