'df.hist() vs. df.plot.hist()?
Solution 1:[1]
They do different things, df.hist() will produce a separate plot for each Series whilst df.plot.hist() will produce a stacked single plot:
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)
produces:
Whilst df.plot.hist(bins=3) produces:
So it's down to what you want, they are convenience functions for different uses.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | EdChum |


