Numpy: multi-dimensional array slicing

preview_player
Показать описание
...in this video, i go over a very high level overview of numpy multidimensional array slicing. first we look at a few array creation functions followed by some attribute methods: nitemsize, shape & ndim. after that, we look at a few examples of slices and a corresponding graphic to get a visual representation of the resulting slice. finally, we look at a few practice examples in the python interpreter. "
practice questions:
# Create a 3D array to use for all the questions
import numpy as np

# 1. Slice the entire array

# 2. Slice the second row of each matrix: array

# 3. Select the first two matrices: array

# 4. Slice the last column of each matrix: array

# 5. Select the middle 2x2 section from each matrix: array

# 6. Slice every second element in the first row: array

# 7. Reverse the order of elements in the second dimension: array

# 8. Extract the last two rows from the last matrix: array

# 9. Slice every element except the first one in each row: array

# 10. Use negative slicing to get the last two columns: array
Рекомендации по теме
Комментарии
Автор

If you don't have NumPy installed run: pip install numpy in the terminal or command prompt

if you're using a Jupyter Notebook, run the following directly in a code cell: !pip install numpy
thanks, for watching!

macroMindGames