Vectorized Maths
Just like a NumPy array, a Series lets you do maths on every value at once — no loops. There are three flavours: maths with a single number, maths between two Series, and asking the Series true/false questions.
1Scalar operations (Series & a single number)
When you combine a Series with one number (a scalar), the operation is applied to every item automatically. The index stays exactly as it was.
+ 5 to ** 2 (power) or - 10 (subtraction) and re-run. Every element updates in one shot.2Vector operations — Pandas aligns by label
When you combine two Series, Pandas doesn't just line them up top-to-bottom. It matches values by their index label. Where a label exists in both, the maths happens. Where a label is missing on either side, the result is NaN. Explore it:
Pandas matches by LABEL, not by position. A label missing on either side becomes NaN. Change the operator.
First, two Series with the same labels — everything matches:
Now watch what happens when the labels don't line up — Rohan and Sneha are missing from the second Series, and Vivaan is new:
3Boolean filtering — ask a true/false question
A comparison (>, <, ==, !=, …) turns a Series into a Series of True/False. Feed that back inside square brackets and Pandas keeps only the rows that were True — all in one line.
scores[scores > 25] as "from scores, give me the items where the score is more than 25". Change 25 to 15 and re-run to see more rows survive.scoresA + scoresB, where label 'Rohan' is only in scoresA. What is the result for 'Rohan'?
What does scores[scores > 25] return?