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. When do you use the binomial distribution?

    Use it to count successes in a fixed number of independent trials, each with the same probability of success. The probability of exactly k successes in n trials is C(n,k) p^k (1-p)^(n-k).

    BeginnerQuick answer1 min read
  2. When would you use pivot_table instead of groupby in pandas?

    pivot_table is groupby with the second key spread across columns, giving a cross-tab style summary. Use it when you want a grid for reading or charting, and groupby when you want a long list of groups.

    BeginnerQuick answer1 min read
  3. Why is the range a weak measure of spread?

    The range is maximum minus minimum, so it depends only on the two most extreme values. One outlier can change it enormously while the rest of the data is unchanged, which makes it unstable. IQR or standard deviation use more of the data.

    BeginnerQuick answer1 min read
  4. How do you check whether data is normally distributed?

    Look first: a histogram and a Q-Q plot, where points hugging the straight line suggest normality. Then optionally confirm with a test such as Shapiro-Wilk, remembering that large samples reject for tiny, harmless deviations.

    IntermediateQuick answer1 min read
  5. How do you decide whether an A/B test result on conversion rate is significant?

    Compare the two conversion rates with a two-proportion z-test: z is the difference in rates divided by the pooled standard error. A p-value below your preset alpha, with a practically useful lift, supports shipping the change.

    IntermediateQuick answer1 min read
  6. 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
  7. How does a two-sample t-test work? Walk through a small example.

    It tests whether two group means differ by more than chance would explain. The t statistic is the difference in means divided by its standard error; a large |t| gives a small p-value and evidence against equal means.

    IntermediateQuick answer1 min read
  8. How does Bayes theorem work? Explain with a medical test example.

    Bayes theorem updates a probability using new evidence: P(A|B) = P(B|A) x P(A) / P(B). It shows that a positive result from an accurate test can still mean a low chance of disease when the disease is rare.

    IntermediateQuick answer1 min read
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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