摘要: import numpy as np A =np.arange(3,15).reshape(3,4) print(A) #第一行 print(A[2]) #返回元素 print(A[1][2]) print(A[1,2]) #返回列 print(A[:,1]) #返回行 print(A[2,:]) #返回一段元素 print(A[1,1:2]) #迭代每一行 for row in A: ... 阅读全文
posted @ 2018-12-08 13:48 萧白白 阅读(377) 评论(0) 推荐(0) 编辑
摘要: import numpy as np #int16和int32内存少,int64内存大但精度高 a = np.array([1,23,4],dtype=np.int32) b = np.zeros((3,4),dtype=np.int16) c = np.arange(10,20,2) #定义一个三行四列的 d = np.arange(12).reshape((3,4)) e = np.... 阅读全文
posted @ 2018-12-08 13:27 萧白白 阅读(175) 评论(0) 推荐(0) 编辑
摘要: import numpy as np array = np.array([[1,2,3], [2,3,4]]) #打印列表 print(array)#是几维的 print('number of dim:',array.ndim)#几行几列 print('shape:',array.shape)#一共有多少个元素 print('size:',array.si... 阅读全文
posted @ 2018-12-07 17:30 萧白白 阅读(159) 评论(0) 推荐(0) 编辑
摘要: # View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg # Youku video tutorial: http://i.youku.com/pythontu... 阅读全文
posted @ 2018-12-07 15:14 萧白白 阅读(166) 评论(0) 推荐(0) 编辑
摘要: # View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg # Youku video tutorial: http://i.youku.com/pythontu... 阅读全文
posted @ 2018-12-07 14:57 萧白白 阅读(211) 评论(0) 推荐(0) 编辑
摘要: import matplotlib.pyplot as plt import numpy as np def f(x,y): # the height function return (1 - x / 2 + x**5 + y**3) * np.exp(-x**2 -y**2) n = 256 x = np.linspace(-3, 3, n) y = np.linspace... 阅读全文
posted @ 2018-12-07 14:47 萧白白 阅读(636) 评论(0) 推荐(0) 编辑
摘要: import matplotlib.pyplot as plt import numpy as np n = 12 X = np.arange(n) Y1 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) Y2 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n) plt.bar(... 阅读全文
posted @ 2018-12-07 14:19 萧白白 阅读(299) 评论(0) 推荐(0) 编辑
摘要: import matplotlib.pyplot as plt import numpy as np n = 1024 X = np.random.normal(0,1,n) Y = np.random.normal(0,1,n) T = np.arctan2(Y,X) #for color value plt.scatter(X,Y,s=75,c=T,alpha=0.5) plt.scat... 阅读全文
posted @ 2018-12-07 13:18 萧白白 阅读(207) 评论(0) 推荐(0) 编辑
摘要: # View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg # Youku video tutorial: http://i.youku.com/pythontu... 阅读全文
posted @ 2018-12-07 10:36 萧白白 阅读(262) 评论(0) 推荐(0) 编辑
摘要: import matplotlib.pyplot as plt import numpy as np x=np.linspace(-3,3,50) y1=x*2+1 y2=x**2 plt.plot(x,y1) plt.figure(num=3,figsize=(8,5)) plt.plot(x,y2) plt.plot(x,y1,color="red",linewidth=1.0,line... 阅读全文
posted @ 2018-12-06 17:54 萧白白 阅读(297) 评论(0) 推荐(0) 编辑