python - Pandas: boxplot of one column based on another column -


say have dataframe following:

my_dataframe:     age  group 0  31   1  24   2  25   3  36   4  50   nan 5  27   6  49   7  24   8  63   9  25   10  65  11  67  12  59  13 nan  b 14  30  b 15  19  b 16  57  b 17  62  b 18  30  b 19  50  b 20  42  b 21  45  c 22  59  c 23  28  c 24  37  c 25  29  c 

i boxplot age of each group (a,b,c). note have nan values in dataframe. how can in pandas?

misread 1st time gave answer histograms... keeking below. boxplot code is:

bp = df.boxplot(by='group') 

enter image description here

suptitle('bla bla') 

to change or rid of automatically generated top title.

might more elegant way following works histograms:

df[df.group =='a'].age.hist() df[df.group =='b'].age.hist() df[df.group =='c'].age.hist() 

http://pandas.pydata.org/pandas-docs/dev/visualization.html has fancy syntax well. since have 3 groups simple solution sufficient.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -