Python Forum
How to group by name and column in box plot - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to group by name and column in box plot (/thread-16898.html)



How to group by name and column in box plot - SriRajesh - Mar-19-2019

Hi,
I have below DataFrame, and I want to visualize the data using box plot and group by Name & column
Category   Var1     Var2      Var3

JAY       1.0        2.4       90
JAY       1.4        3.1       67
JAY       1.0        2.4       90
HKL       0.8        9.1       0.7
HKL       1.5        4.2       2.6
HKL       2.4        8.2       0.7
HKL       1.1        7.2       9.5
HKL       2.8        6.4       0.56
GHT       1.6        5.4       20
GHT       1.8        4.3       6.7
GHT       3.0        5.4       5.7
GHT       0.38       2.5       0.7
GHT       2.8        6.1       4.8
GHT       1.5        0.2       9.2

I want to draw box plot group by Category for each "Var" 
One section of box plot of different Category for Var1, 2nd section is for Different tools of Var2 etc..

I tried as below, but it did not work

import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10,8))
plt.suptitle('')
df.boxplot(column=['Category'], by=['Var1','Var2','Var3'] ax=ax)