2-dimensional numpy Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Cast a list to an array

A
A = np.array(a)
A
array([[11, 12, 13],
       [21, 22, 23],
       [31, 32, 33]])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ndim

A

obtain the number of axes or dimensions referred to as the rank.
a.ndim
2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

shape

A

returns a tuple corresponding to the size or number of each dimension.
A.shape
(3, 3)
go down vertical first and horizontal second

Or total number of nested list first, the number of elements in each nested list second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

size

A

The total number of elements in the array
A.size
9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Obtain elements

A

A[0:2, 2]
array([13, 23])

you first go down the vertical axis along 0:2 before you go across along 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Matrix multiplcation using *

A

Multiplication of two arrays corresponds to an element-wise product or Hadamard product. Consider matrix X and Y. The Hadamard product corresponds to multiplying each of the elements in the same position, i.e. multiplying elements contained in the same color boxes together. The result is a new matrix that is the same size as matrix Y or X, as shown in the following figure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

get transorse

A

C.T
array([[1, 2, 3],
[1, 2, 3]])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly