Side by Side histogram with Pandas from two Series

时间:2019-04-17 00:57:18

标签: python pandas

I have two datafames:

df1:

id,whatever
0,55
1,65
4,45
6,55
8,55
11,98
12,55

df2:

id,whatever
2,55
3,0
5,1
7,1
9,45
10,9
13,12
14,45
15,45

and I would like to plot them on one figure where the 'whatever' is binned in some meaningful way. I can't figure out how to make two histograms on one plot. They can either be overlayed or side by side (not two subplots, but the actual bins from each histogram are side by side).

Attempt:

fig, axes = plt.subplots(1, 2)
df1.hist(bins=5, column='whatever', ax=axes[0])
df2.hist(bins=5, column='whatever', ax=axes[1])
plt.show()

but this gives me two subplots, where I just want one! (it's as close as I got)

Not a duplicate question as this question contains two separate dataframes

0 个答案:

没有答案
相关问题