1

Let's say I have the following data frame:

test = pd.DataFrame({'X': [1,2,3,4,5,6,7,8,9,10], 'Y': [1,2,3,4,5,6,7,8,9,10], 'Season': [1,2,3,2,1,3,2,1,3,2]})
test


    X   Y   Season
0   1   1   1
1   2   2   2
2   3   3   3
3   4   4   2
4   5   5   1
5   6   6   3
6   7   7   2
7   8   8   1
8   9   9   3
9   10  10  2

How could I go about looping through the season column and plotting all the points for said seasons (on different plots)? I've searched questions similar to this and attempted the code, but none seem to be quite the same as this particular situation. Thanks!

EDIT: I would like the plots to be sns regplots if possible

2
  • You can group by and made a plot for each season. Eventually you could made it interactive wit lh a drop-down menu in plotly. Commented May 8, 2020 at 23:16
  • test.groupby('Season').plot(x='X', y='Y')? Commented May 8, 2020 at 23:16

1 Answer 1

3

if you want seaborn regplots, try lmplot:

import seaborn as sns
sns.lmplot(data=test, x='X', y='Y',row='Season')
Sign up to request clarification or add additional context in comments.

Comments

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.