numpy 笔记

题来源

https://github.com/nndl/exercise/blob/master/warmup/numpy_%20tutorial.ipynb

1.引入numpy库

from numpy import *

2.import numpy as np

x =[4,5,6]

a = np.asarray(x, dtype=int)

print (a)

print (a.shape)

print (a.dtype.name)

print (a[0])


3import numpy as np

x =[[4,5,6],[1,2,3]]

b = np.asarray(x, dtype=int)

print (b.shape)

print (b[0][0])

print (b[0][1])

print (b[1][1])

4

import numpy as np

a = np.zeros((3,3),dtype=int)

print(a)

print ("------------")

b = np.ones((4,5),dtype=int)

print(b)

print ("-----------")

c =np.eye(4,dtype=int)

print (c)

print ("------------")

d = np.empty([3,2], dtype = int)

print (d)


4

5

import numpy as np

x =[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]

a = np.asarray(x, dtype=int)

print (a)

print (a[2][3])

print (a[0][0])

5

6

import numpyas np

x =[[1,2,3,4], [5,6,7,8], [9,10,11,12]]

a = np.asarray(x,dtype=int)

b=np.asarray(a[[0,1]])

b=b[:,[1,2]]

print(b)

print(b[0,0])

6

7.

x =[[1,2,3,4], [5,6,7,8], [9,10,11,12]]

a = np.asarray(x,dtype=int)

b=np.asarray(a[[0,1]])

b=b[:,[1,2]]

c=a[1:2][:]

print (c)

print (c[0][-1])


8.

x =[[1,2], [3,4], [5,6]]

a = np.asarray(x,dtype=int)

print(a[[0,1,2], [0,1,0]])


8

9.


10


10

11.


11

12


12

13


13

14.


14

15



16


16

17


17

18.


18

19


19

21


21

22


21

23


23

24.


24

25.

(1)


25(1)

(2)


25(2)

附加:

INF表示“无穷大”,是infinite的缩写。NAN表示“无效数字”,是Not a number的缩写。


问题:

import matplotlib.pyplot出现readtimeout

在file》》setting》》projetct interpreter》》+》》manage repositories把网址修改为下面的和里面不同的另一项


https://pypi.douban.com/simple

https://pypi.python.org/simple

不显示图

如图取消勾选


你可能感兴趣的:(numpy 笔记)