Level 1: NumPy Data Science Exercises
Level 1 teaches NumPy, the library under almost every Python data tool, pandas included. Each exercise is a small job from real data work — converting temperatures, adding up timesheets, cleaning sensor readings — solved without writing a single loop.
Every lesson names one trap that catches beginners, like list * 2
repeating a list or axis=0 meaning columns. Your code runs with real NumPy
in your browser, and the tests check it as soon as you click Run Tests.
The 10 exercises in this level
- 1 NumPy Arrays Maths on every value at once Turn a Python list into a NumPy array and convert a whole list of temperatures in one line, without a loop. Start here — no prerequisites
- 2 NumPy dtypes Text that looks like numbers Data from CSV files and forms often arrives as text. Convert it to real numbers with astype() before doing any maths. Recommended first: NumPy Arrays
- 3 NumPy Sum, Mean & Max Summaries and argmax() Summarize a week of sales with one call each, and find which day was the best with argmax(). Recommended first: NumPy Arrays
- 4 Slicing NumPy Arrays Views, not copies Take the last seven days of a sensor log, and learn why changing a NumPy slice can silently change your original data. Recommended first: NumPy Arrays
- 5 NumPy Boolean Masks Filter with conditions Keep only the readings inside a valid range with a boolean mask, and combine conditions the NumPy way. Recommended first: NumPy Sum, Mean & Max
- 6 Conditional Values with NumPy np.where(condition, a, b) Replace or label every value in one step with np.where(), the vectorized if/else behind data flags and categories. Recommended first: NumPy Boolean Masks
- 7 NumPy 2D Arrays & axis Rows, columns and axis= Work with a table of sales per store and per day, and pick the right axis to total each store. Recommended first: Slicing NumPy Arrays, NumPy Sum, Mean & Max
- 8 NumPy Broadcasting Arrays of different shapes Subtract each column's average from a whole table in one line with broadcasting, the trick behind data normalization. Recommended first: NumPy 2D Arrays & axis
- 9 NaN in NumPy Missing readings A single missing value turns a NumPy average into nan. Spot the gaps with np.isnan() and average around them with np.nanmean(). Recommended first: NumPy Boolean Masks, NumPy dtypes
- 10 Project: NumPy Grade Report Everything from this level Turn a table of exam scores into a small report (class average, best student, pass count) with arrays, axes and masks together. Recommended first: NaN in NumPy, Conditional Values with NumPy, NumPy Broadcasting
Frequently asked questions
- Do I need to install Python or NumPy?
- No. Real Python and NumPy run in your browser. The first exercise you open downloads them once (a few MB); after that they load from your browser's cache.
- Do I need to know Python first?
- You should be comfortable with variables, lists, functions and loops. Level 1 of the Python roadmap covers all of them.
- Why use NumPy instead of Python lists?
- Arrays do maths on every value at once, are far faster on large data, and are what pandas, scikit-learn and Matplotlib are built on.
- What does axis=0 mean?
- `axis=0` works down the columns and gives one result per column; `axis=1` works across each row. The "NumPy 2D Arrays & axis" exercise practises both.