Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.
Start 7-day trial →
⚡
← Courses
›
Data Science Applied
›
Module 6 · Deep Learning + MLOps
›
Pandas: vectorized vs apply vs iterrows
quiz
101 / 104
🇺🇸
EN
▼
↗
Share
⋯
More
+100 XP
📋
Task
📖
Theory
🤖
AI Help
Task
📝 **Question:** Compute c=a+b for 10M rows. Fastest in pandas? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
🎯 Quiz
Question
📝 **Question:** Compute c=a+b for 10M rows. Fastest in pandas? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
A
`df.iterrows()` with a manual accumulator — Cython-backed iteration matches vectorized speed on numeric dtypes.
B
Vectorized: `df['c'] = df['a'] + df['b']`. C-level, no Python loop.
C
`df.apply(lambda r: r.a + r.b, axis=1)` — axis=1 dispatches to NumPy and runs as fast as a column expression.
D
A Python `for i in range(len(df))` loop indexing with `.iat` — pandas has fast scalar access at integer positions.
Submit answer
💬 Discussion
Be the first to ask a question or share a tip.
Sign in
to join the discussion. Reading is free.
Loading discussion…