0

I am passing two lists of coordinates obtained by selectively appending them from my original data frame. I use them to create a boxplot in which the median of those values is drawn.

df = pd.read_csv("path.csv")

# get data from dataframe depending on certain conditions and store it in xValue and yValue
...

g = sns.JointGrid(x=xValues, y=yValues)
g.plot_joint(sns.scatterplot, size=0.1, color='b', linewidth=0)
g.plot_marginals(sns.boxplot, width=0.3, color='b',notch=True, showcaps=False, medianprops={"color": "coral"})

Boxplot will have to compute the median value in order to show it on the graph, so is there any way to get that numerical value?

This question is different from Labeling boxplot in seaborn with median value, Extract outliers from Seaborn Boxplot and Getting values in Seaborn boxplot because these 3 questions use columns directly from the data frame. If you read carefully my question, the data I pass to the boxplot function is an extract of each of the columns of the data frame.

lnlyprog
  • 23
  • 5
  • df.describe() will give you some information for each column of dataframe, such as median, mean, min, max, etc. Or you can use df['column'].describe() to get information for specific column. And you can use df['column'].median() to get only median. Is this what you are looking for? – stukituk Jan 16 '23 at 14:24
  • Not really because the values I am creating the boxplot with are not the ones from the data frame directly. They are extracts from each of the columns of the data frame – lnlyprog Jan 16 '23 at 16:23
  • "If you read carefully my question, the data I pass to the boxplot function is an extract of each of the columns of the data frame." **This does not matter**. For example, it is trivial to *create a new Dataframe* with X and Y columns from the extracted values, or to create separate Series from each, and then use the Pandas functionality shown in those answers. Alternately, answers that *don't* use Pandas functionality and just treat the data as a list, will work perfectly well with an *actual* list. Pandas functionality might also work better for the extraction process than what you have. – Karl Knechtel Feb 04 '23 at 19:03

0 Answers0