1

how can I plot column A as x-axis and B as y-axis with data only related to C. looking for a graph that looks like density graph.

3
  • usa = df[df.Country == 'USA'] selects a subset of rows in the dataframe. To select a subset of columns, such as score & profit, try: usa[['score', 'profit']]. Commented Jan 30, 2022 at 4:47
  • Stackoverflow encourages data (such as your table) to be provided as text rather than an image. This allows responders to more easily post answers using your data. Commented Jan 30, 2022 at 4:54
  • got it, I will do that next time! Commented Jan 30, 2022 at 6:40

1 Answer 1

1

If you are having error while extracting specific columns then, it might be because of extra spaces, just try removing extra space.
Here is code:

usa = df[df.Country == 'USA']
usa.columns = usa.columns.to_series().apply(lambda x: x.strip())
usa[['Score', 'Profit']]

For Density Graph, the question is still unclear, but here density plot based on what I have understood

import seaborn as sns
p=sns.kdeplot(usa['Score'], shade=True, color="r")
p=sns.kdeplot(usa['Profit'], shade=True, color="b")

enter image description here

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

2 Comments

thank you! for second question, I was wondering if there is any plot that I can choose both x and y axis but still looks similar to the density graph (smooth line, not line graph)
Link Do have a look at this question, is this what you are looking for

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.