Just general python data science stuff Flashcards

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

how to iterate over dictionary key-values pairs?

A

for key, value in dictionary.items():

print(key, “ - “, value)

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

create a np array of all the numbers from 0 to 20

A

array = np.arange(21)

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

create a 2d numpy array; all numbers from 0 to 20 in 4 rows of data

A

array = np.arange(20). reshape(4,5)

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

check the shape of a np array “array”

A

array.shape

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

create a np array of the numbers between 50 and 100, increasing in intervals of 5

A

array = np.arange(50, 101, 5)

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

create a np array consisting of all zeros, let’s say with 5 rows of 7 items each.

A

array = np.zeros((5,7))

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

create a np array consisting of all ones, let’s say with 4 rows of 2 items each.

A

array = np.ones((4,2))

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

create a numpy array full of threes, 10 rows of 3 items

A

array = np.full((10,3),3)

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

create a numpy array with 4 numbers, equally spaced between (and including) 0 and 1.

A

array = np.linspace(0,1, num = 4)

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

create a numpy array by straight up typing a list of numbers

A

array = np.array([0,1,2,3,4,5])

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

iterate over all the items in a multi-dimensional numpy array, and - whatever - prints it

A

for item in np.ndinter(array):

print(item)

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

transpose a numpy array

A

npArrayTransposed = np.transpose(npArray)

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