Reputation: 103
I have the following dataset:
pd.DataFrame({'With': data_a[' time'], 'Without': data_b[' time']})
the float number is the time in ms
With
means one experiment completed with help
Without
means one experiment done without help
With Without
0 270147.0 317665.0
1 275627.0 323294.0
2 278488.0 327733.0
3 280900.0 331134.0
4 283299.0 333294.0
5 286000.0 335873.0
6 288231.0 338292.0
7 290408.0 342418.0
8 292512.0 344527.0
9 295838.0 347096.0
10 298021.0 349104.0
11 299893.0 350911.0
12 303356.0 353363.0
13 306205.0 356038.0
14 309123.0 358461.0
15 312196.0 361041.0
I want to display in the x-axis the time taken
I want to display in the y-axis the type of time (With, Without)
this is what I've found that I should use:
seaborn.catplot(
data=<your data variable here>, x = "your x axis name here", y = "your y axis name here", kind="box"
)
however, my x
should be the time taken, and my y
should be the type (with, without)
What should in order to have it as I need?
Upvotes: 0
Views: 502
Reputation: 16172
You may want to stack the dataframe, so that the column headers become a categorical feature.
import pandas as pd
import seaborn as sns
df = pd.DataFrame({'With': [270147.0, 275627.0,
278488.0, 280900.0,
283299.0, 286000.0,
288231.0, 290408.0,
292512.0, 295838.0,
298021.0, 299893.0,
303356.0, 306205.0,
309123.0, 312196.0],
'Without': [317665.0,
323294.0, 327733.0,
331134.0, 333294.0,
335873.0, 338292.0,
342418.0, 344527.0,
347096.0, 349104.0,
350911.0, 353363.0,
356038.0, 358461.0,
361041.0]})
df = df.stack().reset_index()
df.columns=['index','type','time']
sns.catplot(data=df, x='time', y='type')
Upvotes: 1