plot - plotting histograms in pandas -
i looking plot sets of data each 10 points in them in overlapping bins.
values1 = [29, 31, 24, 30, 30, 14, 25, 35, 27, 31] values2 = [36, 29, 29, 29, 34, 33, 27, 34, 36, 39]
when add them dataframe come out 2 columns. looking plot 2 rows each 10 overlapping columns.
df1 = pd.dataframe(values1, values2)
and subsequently when plot them using histograms not come out correctly
df1.plot.hist(stacked = true) plt.show()
so aim pairwise comparison between each of numbers in arrays. 29 - 36 , 31 - 29 , 24 - 29 etc.
i plot them overlap example http://pandas.pydata.org/pandas-docs/stable/_images/hist_new_stacked.png have values instead of 3 in example.
you can pass them values dict:
values1 = [29, 31, 24, 30, 30, 14, 25, 35, 27, 31] values2 = [36, 29, 29, 29, 34, 33, 27, 34, 36, 39] df1 = pd.dataframe({'values1':values1, 'values2':values2}) df1.plot.hist(stacked = true)
what did caused ctor interpret passed values single column of data , index values:
pandas.dataframe(data=none, index=none, columns=none, dtype=none, copy=false)
compare difference:
in [166]: pd.dataframe(values1, values2) out[166]: 0 36 29 29 31 29 24 29 30 34 30 33 14 27 25 34 35 36 27 39 31 in [167]: pd.dataframe({'values1':values1, 'values2':values2}) out[167]: values1 values2 0 29 36 1 31 29 2 24 29 3 30 29 4 30 34 5 14 33 6 25 27 7 35 34 8 27 36 9 31 39
Comments
Post a Comment