Interview Q&A / Data Science

INTERVIEW Q&A · 56 QUESTIONS

Data Science interview questions

Statistics, pandas, cleaning data and exploratory analysis for analyst and data science roles.

  1. How do you handle missing values in a dataset?

    First find how much is missing and why. Then either drop rows or columns (when little is missing or a column is mostly empty) or fill the gaps, using the median for skewed numbers, the mode for categories, forward fill for time series, or a model-based method. Often add a flag column that records which values were missing.

    IntermediateIn-depth4 min read
  2. How do you find rows in one DataFrame that have no match in another?

    Use a left merge with indicator=True and keep rows marked left_only, or filter with ~isin on the key column. This is the pandas version of a SQL anti-join, useful for finding missing records.

    IntermediateQuick answer1 min read
  3. What is the difference between agg and transform in a pandas groupby?

    agg returns one row per group, shrinking the data. transform returns a result with the same length as the original, repeating each group value on every row, so you can add it as a column and do row-level calculations like shares.

    IntermediateQuick answer1 min read
  4. Why is apply slower than vectorised operations in pandas?

    apply runs a Python function once per row or element, paying Python overhead each time. Vectorised operations such as column arithmetic or str methods run in compiled code on whole arrays, and are often tens of times faster.

    IntermediateQuick answer1 min read