Python multidimensional array indexing explanation

Python multidimensional array indexing explanation

Could someone please explain to me what is happening here? I understand what is happening here:&nbsp;<a href="https://docs.scipy.org/doc/numpy-1.15.0/user/basics.indexing.html#index-arrays" target="_blank">https://docs.scipy.org/doc/numpy-1.15.0/user/basics.indexing.html#index-arrays</a>, but do not understand this piece of code.

Could someone please explain to me what is happening here? I understand what is happening here: https://docs.scipy.org/doc/numpy-1.15.0/user/basics.indexing.html#index-arrays, but do not understand this piece of code.

import numpy as np
y = np.zeros((3,3))
y = y.astype(np.int16)
y[1,1] = 1
x = np.ones((3,3))
t = (1-y).astype(np.int16)
print(t)
print(x[t])
x[(1-y).astype(np.int16)] = 0
print(x)

output:

[[1 1 1]
 [1 0 1]
 [1 1 1]]

[[[1. 1. 1.] [1. 1. 1.] [1. 1. 1.]]

[[1. 1. 1.] [1. 1. 1.] [1. 1. 1.]]

[[1. 1. 1.] [1. 1. 1.] [1. 1. 1.]]]

[[0. 0. 0.] [0. 0. 0.] [1. 1. 1.]]


python numpy

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

NumPy Array Tutorial - Python NumPy Array Operations and Methods

Learn about NumPy Array, NumPy Array creation, various array functions, array indexing & Slicing, array operations, methods and dimensions,It also includes array splitting, reshaping, and joining of arrays. Even the other external libraries in Python relate to NumPy arrays.

NumPy in Python | NumPy Python Tutorial | Python Programming

NumPy in Python explains what exactly is Numpy and how it is better than Lists. It also explains various Numpy operations with examples.

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

Introduction to Python NumPy | What is Python NumPy

The NumPy in Python explains what exactly is Numpy and how it is better than Lists. It also explains various Numpy operations with examples.

NumPy Applications - Uses of Numpy

Learn the uses of numpy - Alternate for lists in python, multi dimensional array, mathematical operations. See numpy applications with python libraries.