JuanPablo JuanPablo - 1 year ago 113
Python Question

Pandas plot series with series names in one row

I have a csv file like this

date, name, value
2016-09-01, alice, 10
2016-09-02, alice, 11
2016-09-01, bob, 8
2016-09-02, bob, 14

With pandas can I plot as a line chart? Or must I change the structure of the file to something similar to

date, alice, bob
2016-09-01, 10, 8
2016-09-02, 11, 14

Answer Source

Pivot your dataframe to plot one curve per column:

df.pivot(index='date', columns='name').plot()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download