Two Sigma OA, 3 Questions Passed: 2D Data Points + Pandas Filtering + Asset Returns via Linear Regression
Two Sigma OA recap: 3 questions in 100 minutes covering 2D data point processing, Pandas data filtering, and computing asset returns with linear regression coefficients (beta / alpha), with key concepts and Python reference code.
Overview
- Format: 3 questions, 100 minutes
- Result: passed ✅
| Question | Topic |
|---|---|
| Q1 | Processing 2D data points |
| Q2 | Pandas data filtering |
| Q3 | Linear regression coefficients to compute asset returns |
The question bank is small right now and the bar is relatively low. Happy to discuss!
Q2: Pandas data filtering — common patterns
Two Sigma's data questions care a lot about Pandas fluency. Practice these until you don't need the docs:
import pandas as pd
def filter_trades(df: pd.DataFrame, min_price: float, start: str) -> pd.DataFrame:
"""Keep valid trades with price >= min_price and date >= start, sorted by date"""
df = df.dropna(subset=["price", "volume"])
mask = (df["price"] >= min_price) & (pd.to_datetime(df["date"]) >= pd.Timestamp(start))
return df.loc[mask].sort_values("date").reset_index(drop=True)
def daily_volume_by_symbol(df: pd.DataFrame) -> pd.DataFrame:
"""Daily trading volume per symbol"""
return df.groupby(["symbol", "date"], as_index=False)["volume"].sum()
Note: combine conditions with & / | and wrap each condition in parentheses — and / or won't work.
Q3: Linear regression coefficients → asset returns
A common setup regresses asset returns y on market returns x with simple linear regression y = α + βx:
- β (beta) = Cov(x, y) / Var(x): the asset's sensitivity to market moves
- α (alpha) = mean(y) − β · mean(x)
- Returns usually come from prices via
r_t = P_t / P_{t-1} − 1
def returns(prices):
return [prices[i] / prices[i - 1] - 1 for i in range(1, len(prices))]
def regression(x, y):
"""Simple least squares; returns (alpha, beta)"""
n = len(x)
mx, my = sum(x) / n, sum(y) / n
cov = sum((a - mx) * (b - my) for a, b in zip(x, y))
var = sum((a - mx) ** 2 for a in x)
beta = cov / var
return my - beta * mx, beta
Edge cases: handle price series shorter than 2 and zero variance in market returns separately.
Found this helpful? Let's talk.
Happy to swap interview notes, do mock interviews, or share referral info.

Scan to add me on WeChat
Related notes
- TikTok 2027 CodeSignal OA: Even Digit Count, Cyclic-Shift Difference Sums, Bouncing Diagonals, Most Points in a RangeTikTok · 2026-10-03›
- TikTok Data Science OA, 4 Questions Done in 28 Minutes: Metrics, Table Merges, Feature Preprocessing, Random Forest Threshold TuningTikTok · 2026-10-03›
- TikTok OA, All 4 Passed: Min in a Range, Sorting by Vowel Gap, Bouncing Diagonals, Subarrays with at Least k Fruit PairsTikTok · 2026-10-03›
- Four Classic TikTok OA Questions: Adjacent Character Changes, Closest Earlier Timestamp, Placing Shapes, Fewest Operations to an Arithmetic SequenceTikTok · 2026-10-03›