Pandas.DataFrame.hist()函数有助于理解数字变量的分布。此函数将值拆分为数字变量。其主要功能是制作给定数据帧的直方图。
数据的分布由直方图表示。使用函数Pandas DataFrame.hist()时,它将在DataFrame中的每个系列上自动调用函数matplotlib.pyplot.hist()。结果,我们获得了每列一个直方图。
用法:DataFrame.hist(data, column=None, by=None, grid=True, xlabelsize=None, xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False, sharey=False, figsize=None, layout=None, bins=10, backend=None, legend=False, **kwargs)
参数:
data:DataFrame
column:str或序列
xlabelsize:int,默认值无
ylabelsize:int,默认值无
ax:Matplotlib轴对象,默认为无
**夸克
所有其他绘图关键字参数将传递给matplotlib.pyplot.hist()。
Return:
matplotlib.AxesSubplot或numpy.ndarray
范例1:创建2列Pandas DataFrame 的直方图
有时我们需要绘制 DataFrame 列的直方图,以便对其进行更深入的分析。在这种情况下,dataframe.hist()功能很有帮助。使用此功能,我们可