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 does sample size affect the margin of error in a survey?

    For a proportion, margin of error is about 1.96 x sqrt(p(1-p)/n). It shrinks with the square root of n, so 1000 respondents give roughly +/- 3% and 400 give roughly +/- 5%, and reducing it further gets expensive quickly.

    IntermediateQuick answer1 min read
  2. How does the chi-square test of independence work?

    It compares observed counts in a contingency table with the counts expected if the two categorical variables were independent. The statistic is the sum of (observed - expected)^2 / expected; a large value means the variables are related.

    IntermediateQuick answer1 min read
  3. What are the assumptions of linear regression?

    The main ones are a linear relationship, independent errors, constant error variance (homoscedasticity), roughly normal errors for inference, and no severe multicollinearity. Violations mainly hurt interpretation and confidence intervals rather than raw prediction.

    IntermediateQuick answer1 min read
  4. What does a 95% confidence interval actually mean?

    It comes from a procedure that, if repeated on many samples, would capture the true parameter in about 95% of them. It does not mean there is a 95% probability that this one interval contains the truth.

    IntermediateQuick answer1 min read
  5. What does the exponential distribution model?

    The exponential distribution models the waiting time until the next event when events arrive randomly at a constant rate. It is memoryless: the time already waited does not change the remaining wait.

    IntermediateQuick answer1 min read
  6. What is a residual, and what can a residual plot tell you?

    A residual is actual minus predicted. Plotting residuals against fitted values should look like random scatter around zero; curves, fans or clusters reveal non-linearity, changing variance or missing variables.

    IntermediateQuick answer1 min read
  7. What is multicollinearity, and how do you detect it?

    Multicollinearity is when predictors are strongly correlated with each other, which makes coefficient estimates unstable and hard to interpret. Detect it with a correlation matrix or variance inflation factor; VIF above about 5 to 10 is a warning.

    IntermediateQuick answer1 min read
  8. What is the birthday paradox?

    In a group of just 23 people, the chance that two share a birthday is about 51%. It feels surprising because the number of pairs grows fast: 23 people form 253 pairs, each a chance for a match.

    IntermediateQuick answer1 min read
  9. What is the coefficient of variation, and when is it useful?

    The coefficient of variation is standard deviation divided by mean, often shown as a percentage. It measures relative spread, so you can compare variability between datasets with different units or very different averages.

    IntermediateQuick answer1 min read
  10. What is the difference between a one-tailed and a two-tailed test?

    A two-tailed test looks for a difference in either direction; a one-tailed test looks only for an increase or only for a decrease. The one-tailed p-value is half the two-tailed one, so the direction must be decided before seeing data.

    IntermediateQuick answer1 min read
  11. 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
  12. What is the difference between the Law of Large Numbers and the Central Limit Theorem?

    The Law of Large Numbers says the sample mean converges to the true mean as n grows. The Central Limit Theorem describes the shape and spread of the sample mean around that true value: approximately normal with SD sigma over root n.

    IntermediateQuick answer1 min read
  13. What is the Poisson distribution, and what kind of data does it model?

    Poisson models the number of events in a fixed interval of time or space when events occur independently at a constant average rate. It has one parameter, the rate lambda, which is both its mean and its variance.

    IntermediateQuick answer1 min read
  14. When do you use a paired t-test instead of an independent t-test?

    Use a paired t-test when the two measurements come from the same subjects or matched pairs, such as before and after. It tests whether the mean of the differences is zero, which removes person-to-person variation.

    IntermediateQuick answer1 min read
  15. Why are incomes and prices right-skewed, and why does a log transform help?

    Such values grow by percentages rather than fixed amounts, so many small effects multiply and produce a long right tail (log-normal shape). Taking the log turns multiplication into addition and usually makes the data close to symmetric.

    IntermediateQuick answer1 min read
  16. Why do we divide by n-1 when computing sample variance?

    A sample sits closer to its own mean than to the true population mean, so dividing by n underestimates the population variance. Dividing by n-1 (Bessel correction) removes that bias on average.

    IntermediateQuick answer1 min read
  17. 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
  18. Why is peeking at an A/B test or running many tests a problem?

    Each extra look or extra comparison gives another chance of a false positive. With alpha 0.05, 20 independent tests give about a 64% chance of at least one false hit. Fix sample size in advance and correct for multiple comparisons.

    AdvancedQuick answer1 min read