Interview Q&A / Data Science
Data Science interview questions
Statistics, pandas, cleaning data and exploratory analysis for analyst and data science roles.
Prefer rapid revision? Practise Data Science short interview answers →
- How does groupby work in pandas?
groupby splits the rows into groups by key, applies a function such as sum or count to each group, and combines the results into a new object. Named aggregation lets you compute several summaries in one call.
BeginnerQuick answer1 min read - 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