DS 1501 · Lesson 21 of 24
Instructor: Bro Code1h 0m
Sign in to watchManipulate 2D matrices, filter datasets with boolean masks, reshape tables without copying unnecessarily, and compute axis-wise Data Science aggregations. What you will learn: • 2D matrix indexing and slicing: matrix[row_slice, col_slice] (and view vs copy semantics — modifying a slice mutates the parent array!). • Boolean masking / fancy filtering: arr[arr > 75] and compound conditions with & and |. • Reshaping & stacking: reshape(), flatten() vs ravel(), transpose (.T), vstack, and hstack. • Statistical aggregations & axes: sum, mean, std, var, min, max, argmin, argmax along axis=0 (down columns) vs axis=1 (across rows). • Broadcasting rules for combining arrays of different shapes. University Outline Mapping: Class 21 · CO4 · Reading: Chapter 7 (deitel) · Activities: Lecture, Slides, Demonstration.
Note
Outline: Class 21 | CO4 | Reading: Deitel Chapter 7 High-Frequency NumPy Exam Traps: • Slices return VIEWS, not copies! Use .copy() when you need an independent sub-array. • axis=0 collapses rows (gives one result PER COLUMN); axis=1 collapses columns (gives one result PER ROW). • Boolean filtering uses bitwise operators with parentheses: arr[(arr >= 10) & (arr <= 20)], NEVER Python 'and'.
Same resources as in the community course — sign in to watch the lesson and track progress.
Watch the whole course.
Sign in to play every lesson, track your progress, and ask questions alongside the community.
Already signed in? Open lesson in Community