numpy
overview
fast computation involving arrays and matrices
numpy
arrays
- homogeneous - all values are of the same type
- (potentially) multi-dimensional
numpy
computation is fast because
- much of it is implemented in
C
numpy
arrays are stored more efficiently in memory than Python lists
array.argmax()
gets the first index of the max element in the array
for loop vs. vectorized arithmetic in numpy
2D arrays
Using axis to compress along axes for computations
Using square brackets to index using same slicing as Python or commas
Pictures as numpy arrays
Each image has pixels of RGB
Grayscale by averaging RGB values
Sepia filter
Pandas
DataFrame: 2d tables
Series: 1d array-like object
Index: sequence of column or row labels
- The standard way to select a column in
pandas
is by using the[]
operator - Specifying a column name returns a Series
- Specifying a list of column names returns a DataFrame
Querying with multiple conditions: use &
and |
Querying using .query()
- can use and
and ignore parentheses