How to draw line chart using pandas or matplotlib?

Question:

I have a table like below:

date  category  num
xxx      a       10
xxx      b       23
xxx      c       11
..........

I want to draw a line chart that: 1. x axis is the time series, 2. y is the num, and 3. each category gets their own line, so in the above case there should be 3 lines.

Asked By: Karl T

||

Answers:

Use seaborn lineplot.

sns.lineplot(x='date',y='num, data=df, hue='category',palette='bright) 

Using hue should give you 3 separate graph.

You can also use matplotlib.
Here is the documentation for that:
https://seaborn.pydata.org/generated/seaborn.lineplot.html

Answered By: kas
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.