File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 1111 np.random.seed(123456 )
1212 from pandas import *
1313 options.display.max_rows= 15
14+ options.display.mpl_style= ' default'
1415 import pandas as pd
1516 randn = np.random.randn
1617 randint = np.random.randint
@@ -346,6 +347,24 @@ The :ref:`Plotting <visualization>` docs.
346347`Generate Embedded plots in excel files using Pandas, Vincent and xlsxwriter
347348<http://pandas-xlsxwriter-charts.readthedocs.org/en/latest/introduction.html> `__
348349
350+ `Boxplot for each quartile of a stratifying variable
351+ <http://stackoverflow.com/questions/23232989/boxplot-stratified-by-column-in-python-pandas> `__
352+
353+ .. ipython :: python
354+
355+ df = pd.DataFrame(
356+ {u ' stratifying_var' : np.random.uniform(0 , 100 , 20 ),
357+ u ' price' : np.random.normal(100 , 5 , 20 )}
358+ )
359+ df[u ' quartiles' ] = pd.qcut(
360+ df[u ' stratifying_var' ],
361+ 4 ,
362+ labels = [u ' 0-25%' , u ' 25-50%' , u ' 50-75%' , u ' 75-100%' ]
363+ )
364+
365+ @savefig quartile_boxplot.png
366+ df.boxplot(column = u ' price' , by = u ' quartiles' )
367+
349368
350369 Data In/Out
351370-----------
You can’t perform that action at this time.
0 commit comments