numpy Flashcards

1
Q

create an array [a,…, n] with step size x

A

numpy.arange(a, n+1, x)

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

add arr2 to the end of arr1

A

numpy.append(arr1, arr2)

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

calculate std for arr

A

np.std(arr, ddof = 1)

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

calculate the covariance of two arrs

A

np.cov(x,y)[0,1]

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

calculate the correlation coefficient of two arrs

A

np.corrcoef(x, y)[0,1]

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

the product of all elements in an array x

A

np.prod(x)

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

create a new array and its elements are element wise sums from arr1 and arr2.

A

x = arr1 + arr2

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

get an array of k zeros in it

A

numpy.zeros(k)

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

mean of arr

A

arr.mean() or numpy.mean(arr)

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

median of arr

A

np.median(arr)

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

variance of an array

A

np.var(arr, ddof =1)

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

the covariance of the two arrays

A

np.cov(arr1, arr2)[0,1]

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

the covariance matrix of the two arrays

A

np.cov(arr1, arr2)

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

correlation coefficient matrix of two arrays

A

np.corrcoef(arr1,arr2)

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

log transform a column

A

df[‘log_value’] = np.log(df[‘value’])

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