1、在jupyter notebook中要想支持多行输出需要加入一下两行代码:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all' #默认为'last'
2、Windows环境下中文的正常显示:
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
3、ndarry介绍
4、a = np.array([80,89,86,67,79])
,转换为列表:a.tolist()
5、ndarry的运算效率比python原生的list要高
6、ndarray属性,
7、常用数组的生成
np.zeros((3,3))
np.ones((3,3))
np.random.random((3,3))
np.random.uniform(-1,1,(5,3))
np.random.randn(5,2)
np.random.permutation(np.arange(10))
8、随机数种子
import numpy as np
nrg = np.random.RandomState(0)
nrg.randn(5,2)
加了随机种子以后,每次随机的产生的数组就是一样的了,也就是说,只要种子一样,无论在那台电脑里生成的数据都一样。一般情况下是为了复现代码。
9、数组的切片操作(假设数组是scores)
scores[0, :3]
scores[:,3]
scores[0]或scores[0,:]
scores[[1,3,6]]
scores[scores>5]
10、形状改变
活动地址:CSDN21天学习挑战赛