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 11
11
np.random.seed(123456 )
12
12
from pandas import *
13
13
options.display.max_rows= 15
14
+ options.display.mpl_style= ' default'
14
15
import pandas as pd
15
16
randn = np.random.randn
16
17
randint = np.random.randint
@@ -346,6 +347,24 @@ The :ref:`Plotting <visualization>` docs.
346
347
`Generate Embedded plots in excel files using Pandas, Vincent and xlsxwriter
347
348
<http://pandas-xlsxwriter-charts.readthedocs.org/en/latest/introduction.html> `__
348
349
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
+
349
368
350
369
Data In/Out
351
370
-----------
You can’t perform that action at this time.
0 commit comments