对不起,如果我的问题看起来很基本,但我找不到直接的答案。目前正在学习 pandas 可视化,但不了解 df.hist()
与 df.plot.hist()
之间的区别(参见 here 和 here , 分别)。有人能启发我吗?
最佳答案
他们做不同的事情,df.hist()
将为每个 Series
生成单独的图,而 df.plot.hist()
将产生一个堆叠的单图:
df = pd.DataFrame({
... 'length': [1.5, 0.5, 1.2, 0.9, 3],
... 'width': [0.7, 0.2, 0.15, 0.2, 1.1]
... }, index= ['pig', 'rabbit', 'duck', 'chicken', 'horse'])
df.hist(bins=3)
产生:
虽然 df.plot.hist(bins=3)
产生:
所以这取决于你想要什么,它们是用于不同用途的便利功能。
关于python - df.hist() 与 df.plot.hist()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57008086/