0

I would like to plot a line showing the ranking of each of these roller coasters as a function of the year that they were ranked. For example for the second row (Boulder Dash, I would like a line graph showing the value 1 for 2013-2016, and then 3 and 4 for 2017 and 2018, respectively.

Since the years will be constant for each different coaster, I tried setting the x-axis with: x = range(6) then I would like to plot: plot(x, ranking) for each different roller coaster. What I am confused about is how to get those y values (rating) in a format that could be plotted. Roller Coaster DataFrame

gogis
  • 11
  • Please see [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – BigBen Apr 24 '20 at 19:09

1 Answers1

0

Based on the dataframe from the image, I would use seaborn line plot that already implements a hue parameter, but first, reset the Name index and melt the dataframe:

import seaborn as sns

df_melted = df.reset_index().melt(id_vars=['Name'])
sns.lineplot(data = df_melted, x='Year of Rank', y ='value', hue='Name')
jcaliz
  • 3,891
  • 2
  • 9
  • 13