Reputation: 71
I have a dataframe which looks like the table below with 10 records. The columns names are the years. I will like to plot the records so I can visualize the yearly trend of the data with the years as my X axis. How can I achieve this?
+------+------+------+------+
| 2015 | 2016 | 2017 | 2018 |
+------+------+------+------+
| 31 | 25 | 32 | 57 |
| 23 | 54 | 28 | 29 |
| 30 | 25 | 37 | 44 |
| 31 | 25 | 32 | 57 |
+------+------+------+------+
Upvotes: 0
Views: 1179
Reputation: 76
You can use the following code shown as in below:
import pandas as pd
dct = {'2015':['31','23','30','31'],
'2016':['25'],[54],[25],[25]}
df=pd.DataFrame(dct).melt()
df.plot(x=’Value’, y=’Year’)
plt.show()
If you change the view of graph you can use such as "color", "marker","markersize" parameters.
Upvotes: 1