VivaPrep
← All modules

Python / SQL / Data Manipulation

pandas fluency, basic SQL (SELECT/JOIN/GROUP BY), numpy from-scratch drills.

Start here

Practical fluency, not cleverness. Two toolkits matter:

  • — math on whole arrays at once, very fast (no Python loops). builds on it: a is a spreadsheet you manipulate with code — filter rows, group + summarize, two tables on a shared column.
  • SQL — same job, for data living in a database. SELECT picks columns, WHERE filters rows before grouping, buckets rows sharing a value, HAVING filters after that, combines tables on a shared column.

The viva-specific twist: you may be asked to implement something like "compute from predictions" using bare , no shortcuts — checking you understand what's inside the black box, not whether you memorized a one-line library call.

Core threads

  • : filtering (`df[df.col > x]`), grouping (`groupby().agg()`), merging (`merge` = SQL equivalent), handling missing data (`fillna`/`dropna`) — these cover 90% of asked operations.
  • SQL: SELECT + WHERE + + HAVING + (INNER vs LEFT — know the difference cold) is the expected level, not window functions or CTEs (though a bonus if you know them).
  • from scratch: be able to implement, without sklearn: train/test split (shuffle + slice), // ( counts), and (distance matrix + argsort + majority vote). These are classic "write it live" prompts because they test understanding, not memorization of an API.
  • Why "from scratch" matters: a candidate who can only call `sklearn.metrics.accuracy_score` but can't say what it computes internally raises a flag — the board is testing understanding through implementation.

Viva angle

If asked to write /SQL on paper, narrate your reasoning (which column, why groupby, why that type) — it shows understanding even if exact syntax slips.

Visual reference

INNER vs LEFT JOIN

INNER JOINLEFT JOIN
INNER JOIN keeps only the overlap between two tables. LEFT JOIN keeps everything from the left table, filling in NULLs where the right table has no match.

Cheatsheet

SQL clause order

ClausePurpose
SELECTPick columns
WHEREFilter rows before grouping
GROUP BYBucket rows sharing a value
HAVINGFilter after grouping (on aggregates)
ORDER BYSort results

JOIN types

TypeReturns
INNER JOINOnly rows matching in both tables
LEFT JOINAll left rows, NULLs where no match on the right

pandas quick reference

TaskCode
Filter rowsdf[df.col > x]
Group + aggregatedf.groupby('col').agg(...)
Join two tablesdf.merge(other, on='key')
Fill missingdf.fillna(value)
  • core: distances → np.argsort → majority vote of nearest K labels.
  • Always shuffle before a train/test split unless order is meaningful (time series).

Further study

Question bank

17 questions
#1Mediumnumpyfrom-scratch

Describe how you would implement a train/test split from scratch using (no sklearn).

#2Mediumnumpyfrom-scratchmetrics

Describe how to compute , , and from scratch given predicted and true labels.

#3Hardnumpyfrom-scratchknn

Describe how to implement classification from scratch.

#4Easypandas

How do you handle missing values in a ? Name a few strategies.

#5Easypandas

What does groupby().agg() do in ? Give an example use case.

#6Mediumsql

What is the difference between INNER and LEFT in SQL?

#7Mediumsql

Write a SQL query to find the top 3 users by total transaction amount from a `transactions(user_id, amount, created_at)` table.

#8Easysql

What is the difference between WHERE and HAVING in SQL?

#9Easypythoncoding

Write Python code (or describe it) to find all divisors of a number N efficiently.

#10Easypython

What is the difference between a Python list and a array, performance-wise?

#11Mediumsqlwindow-functions

What can ROW_NUMBER() or () (window functions) do that a plain can't?

#12Mediumsql

What is the difference between a SQL subquery and a CTE (the WITH clause), and why are CTEs often preferred?

#13Easypandas

What does ' pivot_table do, and when would you use it?

#14Easyvectorization

What does 'vectorization' mean in general, beyond just , and why is it faster than an explicit loop?

#15Easysqlindexes

Why do indexes speed up SQL queries — what's the mental ?

#16Easysql

What changes when you multiple columns instead of one, and what's an example use case?

#17Easysqldata-cleaningbKash

Write a SQL query to find duplicate values in a column — e.g. users sharing the same phone number.