Back to marketplace

Numpy (Wk 3 UCSD / DataCamp)

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v3•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

How does a (numpy) array differ from a list?

Back (Answer)

You can perform mathematical operations element wise on the array (vector arithmetic)

#2
Front (Question)

How do you create a numpy array?

Back (Answer)

np_array = np.array(list) OR np.array([x, y, z])

#3
Front (Question)

What happens if you divide 2 np arrays (of the same size)

Back (Answer)

the output is the an array of the same size, w/ each element the respective quotients

#4
Front (Question)

What happens if you create a numpy array of multiple types?

Back (Answer)

it will convert all to one type (aka type coercion)

#5
Front (Question)

what’s the output of np_array > X

Back (Answer)

Array of Booleans element wise [True, False, etc]

#6
Front (Question)

What’s the output of np_array[ np_array > X]

Back (Answer)

Returns element wise values that meet the condition (product w/ Boolean result)

#7
Front (Question)

When do you use parentheses with an array?

Back (Answer)

When you’re instantiating only (eg, not when you’re setting or sub-setting

#8
Front (Question)

How do you create a multi-dimensional np array?

Back (Answer)

np_array = np.array(list1, list2) OR = np.array( [ [1,2,3], [4,5,6] ] )

#9
Front (Question)

How do you get the number of rows and columns of an array?

Back (Answer)

np_array.shape (attribute of the array)

#10
Front (Question)

How do return 2nd element from 3rd row of a 2d np array?

Back (Answer)

np_array[2,1] OR np_array[2][1]

#11
Front (Question)

How do you sub-set multi-dimensional np arrays?

Back (Answer)

np_array[ x:y, k:j ]

#12
Front (Question)

using subsetting, return the entire second row of a np array

Back (Answer)

np_array[ 1, : ]

#13
Front (Question)

How does arithmetic work with multi-dim arrays?

Back (Answer)

can do all operations. Array X Array, or Array X Vector(s)

#14
Front (Question)

Get the mean of the first column of data in a 2D np array

Back (Answer)

np.mean(np_array[ : , 0]

#15
Front (Question)

summary stats functions np arrays

Back (Answer)

np.mean(), np.median(), np.std()

#16
Front (Question)

check the corrleation between column 1 and column 2 in a 2D array

Back (Answer)

np.corrcoef( np_array[ : , 0] , np_array[ : , 1] )

#17
Front (Question)

How to generate an array with normally distributed random numbers

Back (Answer)

np.random.normal(mean, std, num of values to generate)

#18
Front (Question)

how to merge two 1D arrays into a single 2D array

Back (Answer)

np_2d = np.column_stack(( np1, np2))

#19
Front (Question)

create arrays full of 0s, 1s, diagonal 1

Back (Answer)

np.zeros, np.ones, np,eye

#20
Front (Question)

create 2d array with all value 9

Back (Answer)

np_array = np.full((2,2), 9.0)

#21
Front (Question)

create a 2d array with random floats between 0 and 1

Back (Answer)

np_array = np.random.random((2,2))

#22
Front (Question)

What does a sub-set of an array like a_slice = np_array[1:3 , 1:3 ]

Back (Answer)

a 2x2 array that you can reference with the new indices (eg 0,0; 0,1; etc), but points to the same data as the original array

#23
Front (Question)

how do you make a new data structure using a slice

Back (Answer)

new_slice = np.array(np_array[1:2, 2:3]

#24
Front (Question)

explicitly declare the data type in an array

Back (Answer)

x = np.array(list1, dtype=float64)»_space; forces to the dtype, can use various types