How to use seaborn to draw boxplot by choosing specific row?
You can select B and A from variable by
df.loc[(df.variable == "A") & (df.variable == "B")]
Then Transpose the df by:
df_T = df.loc[(df.variable == "A") | (df.variable == "B")].T
Then sns:
sns.boxplot(x='variable', y = 'value', data = df_T)
index
variable
value




0
A
up


1
A
down


2
A
up


3
A
up


4
B
down


5
B
up


6
B
down


7
B
up


8
C
up


9
C
up


10
C
down


11
C
down


12
D
up


13
D
down


14
D
down


15
D
up




For example, I want to draw a boxplot by using seaborn to show values in (variable =A and variable=B). How can I solve it?
AS before, the row table contain attributes{"variableA", "variableB","variableC","variableD","value"}
so I can use :
sns.boxplot(x=df["variableA"],y=df["variableB],order=["up","down"])
And now I got a melt table(tidy dataframe). How to draw the same picture?