File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -1705,12 +1705,36 @@ import numpy as np
1705
1705
```
1706
1706
1707
1707
``` python
1708
- < el_or_array> = < array> [:,0 ] # First column.
1709
- < el_or_array> = < array> .sum([< axis> ]) # Axis is an index of dimension that gets collapsed.
1710
- < el_or_array> = < array> .argmin([< axis> ]) # Returns index/es of smallest elements.
1711
- < el_or_array> = < array> [filter_expression]
1708
+ < el_or_array> = < array> .sum([< axis> ]) # Axis is an index of dimension that gets collapsed.
1709
+ < el_or_array> = < array> .argmin([< axis> ]) # Returns index/es of smallest element/s.
1712
1710
```
1713
1711
1712
+ ### Indexing
1713
+ #### Basic indexing
1714
+ ``` python
1715
+ < el> = < 2d_array > [0 , 0 ]
1716
+ ```
1717
+
1718
+ #### Basic slicing
1719
+ ``` python
1720
+ < 1d_view > = < 2d_array > [0 ] # First row.
1721
+ < 1d_view > = < 2d_array > [:, 0 ] # First column. Also [..., 0].
1722
+ < 3d_view > = < 2d_array > [None ,:,:] # Expanded by dimension of size 1.
1723
+ ```
1724
+
1725
+ #### Integer array indexing
1726
+ ** If row and column indexes differ in shape, they are combined with broadcasting.**
1727
+ ``` python
1728
+ < 1d_array > = < 2d_array > [< 1d_row_indexes > , < 1d_column_indexes > ]
1729
+ < 2d_array > = < 2d_array > [< 2d_row_indexes > , < 2d_column_indexes > ]
1730
+ ```
1731
+
1732
+ #### Boolean array indexing
1733
+ ``` python
1734
+ < 2d_bool_array > = < 2d_array > > 0
1735
+ < 1d_array > = < 2d_array > [< 2d_bool_array > ]
1736
+ ``
1737
+
1714
1738
# ## Broadcasting
1715
1739
** Broadcasting is a set of rules by which NumPy functions operate on arrays of different sizes and / or dimensions.**
1716
1740
```python
You can’t perform that action at this time.
0 commit comments