1

I have dataframe:

id meters availability1 availability2 availability3 0 0 70 80 90 1 50 75 75 80 2 100 100 90 100 3 150 87 85 80 4 200 60 90 100 

I want to create a box plot that shows me what is availability for each specific meter. For example for 0-meter availability is from 90 to 70. So I want to create box plot for each row, not column. I can not found how to apply this not changing the structure of my dataframe.

The code that I use is the following:

import pandas as pd import matplotlib.pyplot as plt import seaborn as sns file = 'D:\\test_box_plot.csv' df = pd.read_csv(file, sep = ";", usecols = ['availability1','availability2','availability3']) sns.boxplot(x="variable", y="value", data=pd.melt(df)) plt.show() 

I will appreciate any help

1 Answer 1

1

I think it's a possible solution, but I am not quite sure if I've understood what you wanted:

 boxMeters = sns.boxplot(x=0,y=1,data=df.transpose(), palette="Set3") 

The trick here is to work with a transposed matrix of your dataframe. I suggest you to print the transposed dataframe to know how to reference every column.

With the data you posted, my transposed dataframe is:

 0 1 2 3 4 id 0 1 2 3 4 meters 0 50 100 150 200 availability1 70 75 100 87 60 availability2 80 75 90 85 90 availability3 90 80 100 80 100 

"meters" is just below the column addressed as 0 and the availability1 is the column 1. You tell me if it works for you.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your help!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.