Shaping, ordering and statistics
Reshaping and joining arrays, sorting, unique values and binary search, and descriptive statistics with percentiles and histograms.
About 5 hours of study
Learning objectives
- Reshape and join arrays
- Sort and search arrays
- Describe data with NumPy's statistics
Lessons
- 1
Reshaping and stacking Intermediate
Changing an array's shape without changing its data: reshape and the -1 shortcut, flatten and ravel, transposing with .T, and joining arrays with concatenate, vstack, hstack and stack.
- 2
Sorting, unique values and searching Intermediate
Ordering and finding data with NumPy: np.sort and the in-place sort, argsort for the order of positions, unique values with counts, and fast binary search in sorted arrays with searchsorted.
- 3
Statistics with NumPy Intermediate
Describing data with NumPy: mean, median and std (and the ddof trap), percentiles with linear interpolation, histograms with np.histogram, correlation with np.corrcoef, and standardising columns.
Module practice
- NumPy: Work out a reshapeEasy
- NumPy: Transpose and printMedium
- NumPy: Concatenate two matricesHard
- NumPy: A stable argsortEasy
- NumPy: Unique values and countsMedium
- NumPy: searchsorted, left and rightHard
- NumPy: Percentiles with interpolationEasy
- NumPy: np.histogram by handMedium
- NumPy: Standardise each columnHard