# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Conditional and Slice Selection

import numpy as np

arr = np.arange(0,9)

arr = arr.reshape(3,3)

up_to_five = arr < 6
up_to_five

arr[up_to_five]

# it's equivalent to the above but in one go
arr[arr < 6]

arr = np.arange(40).reshape(8,5)

# any boolean operation applicable to the datatype contained in the array
arr[arr % 2 == 0]

arr

# slice notation to get an internal sub matrix
arr[1:5, 1:4]

arr[:3,3:]



StarcoderdataJupyterScriptsDedupFiltered