numpy basic 1 Flashcards

data type, array creation func (29 cards)

1
Q

int8, uint8

A

i1, u1

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

int16, uint16,

A

i2, u2

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

int32, uint32

A

i4 , u4

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

int64, uint64

A

i8, u8

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

float16

A

f2

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

float32

A

f4 or f

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

float64

A

f8 or d

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

float128

A

f16 or g

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

complex64

A

c8 c16

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

complex128

A

c32

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

bool

A

?

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

object

A

0

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

string

A

S

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

unicode

A

U

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

array

Convert input data (list, tuple, array, or other sequence type) to an ndarray either by inferring a dtype
or explicitly specifying a dtype; copies the input data by default

A

In [19]: data1 = [6, 7.5, 8, 0, 1]
In [20]: arr1 = np.array(data1)
In [21]: arr1
Out[21]: array([ 6. , 7.5, 8. , 0. , 1. ])

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

asarray

Convert input to ndarray, but do not copy if the input is already an ndarray

A

no shit seen look into the future

17
Q

arange Like the built-in range but returns an ndarray instead of a list

A

In [32]: np.arange(15) Out[32]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

18
Q

arange Like the built-in range but returns an ndarray instead of a list

A

In [32]: np.arange(15)

Out[32]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

19
Q

ones, zeros, empty ,full

A

quite the same hope u didn’t forget

20
Q

ones_like, zeros_like, empty_like , full like

A

makes a arr full of value like the arr given as arg

21
Q

np.astype

A

In [44]: numeric_strings = np.array([‘1.25’, ‘-9.6’, ‘42’], dtype=np.string_)
In [45]: numeric_strings.astype(float)
Out[45]: array([ 1.25, -9.6 , 42. ])

22
Q

arr 1d index and slicing prblm
arr = np.arange(10)
arr[5:8] = ?

A

Out[63]: array([5, 6, 7])

23
Q

arr2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

In [73]: arr2d[2]
= ?

A

Out[73]: array([7, 8, 9])

24
Q

arr2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

In [74]: arr2d[0][2] and arr2d[0, 2]
output?

25
arr = [1,2,3,4] | what are the index of each value in arr
1=0 2=1 3=2 4=3
26
.copy()
to copy an arr
27
if arr_1 = [1,2,3] arr_2 =[ [5,6,7], [8,9,0] ] how to transform the first value of arr_2 to arr_1 expected value = [[1,2,3], [8,9,0]]
arr_2[0] = arr_1 | arr_2
28
how to have dot product of arr1 and arr2
np.dot(arr1, arr2)
29
how to create transpose of an arr
``` arr.T Simple transposing with .T is a special case of swapping axes. ndarray has the method swapaxes, which takes a pair of axis numbers and switches the indicated axes to rear‐ range the data: In [135]: arr Out[135]: array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7]], [[ 8, 9, 10, 11], [12, 13, 14, 15]]]) In [136]: arr.swapaxes(1, 2) Out[136]: array([[[ 0, 4], [ 1, 5], [ 2, 6], [ 3, 7]], [[ 8, 12], [ 9, 13], [10, 14], [11, 15]]]) ```