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 →
- What is the difference between merge, join and concat in pandas?
merge combines two DataFrames on matching column values, like a SQL join. join does the same but matches on the index by default. concat simply stacks DataFrames on top of each other (rows) or side by side (columns) without matching any keys.
BeginnerIn-depth3 min read - How do you find and handle missing values in pandas?
Use isna().sum() to count them, then dropna to remove rows or columns, or fillna to fill them with a constant, mean, median or group value. Check what share is missing first, since the right fix depends on it.
BeginnerQuick answer1 min read - 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 loc and iloc in pandas?
loc selects by label (index values and column names) and includes the end of a slice. iloc selects by integer position and excludes the end, like normal Python slicing.
BeginnerQuick answer1 min read - 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