numpy中基础操作2

numpy中min与max

也就是说numpy.min与numpy.amin是等价函数

对numpy.max与numpy.amax同理

numpy中数据舍入操作

numpy中查看数据直方图分布

# 指定统计区间 #
a = np.random.rand(100)
hist, bin_edges = np.histogram(a, bins=5)
# 指定统计区间 #
a = np.random.rand(100)
hist, bin_edges = np.histogram(a, bins=5, range=(0, 1))

Matplotlib基于Numpy的histogram进行了多样化的封装并提供了更加完善的可视化功能

#####################################################################
# matplotlib绘图 #
# matplotlib.axes.Axes.hist() 方法的接口
n, bins, patches = plt.hist(x=a, bins='auto', color='#0504aa', alpha=0.7, rwidth=0.85)
plt.show()

pandas的Series也提供了hist绘图

#####################################################################
# pd.Series绘图 #
a_ss = pd.Series(a.ravel())
a_ss.plot.hist(grid=True, bins=20, rwidth=0.9, color='#607c8e')
plt.show()