0
$\begingroup$

I have a big dataframe that consists of male and female shoe sizes. I am currently trying to plot size versus height for male and female separately. I have tried to slice the data and stored it in different variables, however I get an error when I try to plot it.

enter image description here

Here I tried to obrain rows that are only female height and shoe size

female_height = df.loc[(df[1] == 'F'), 3]
female_size = df.loc[(df[1] == 'F'), 2]

Here I tried to obrain rows that are only female height and shoe size

male_height = df.loc[(df[1] == 'M'), 3]
male_size = df.loc[(df[1] == 'M'), 2]

when I try to do the first plot only for female size and height I get this error:

sns.scatterplot(x='female_height', y='female_size', data=df)
plt.show()

enter image description here

I tested the columns and it displays exactly what I need, so what is causing this error?

$\endgroup$
0

1 Answer 1

1
$\begingroup$

The code sns.scatterplot(x='female_height', y='female_size', data=df) is saying to plot the female_height and female_size columns of the dataframe df. But you have created separate variables called female_height and female_size, not created them as columns in your dataframe. If you plot these variables using sns.scatterplot(x=female_height, y=female_size) it should work.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.