Reputation: 19
I have a dataframe with three columns. I did a group by on two columns and calculated mean. I reset the index after mean. Now i would like to plot on the graph.
My columns are
Type Time Value
A 0:15:00 5.3718
0:30:00 3.4776
0:45:00 5.6616
1:00:00 0.1638
1:15:00 5.2206
1:30:00 2.6544
1:45:00 0.2982
2:00:00 0.1638
B 0:15:00 6.8376
0:30:00 0.3402
0:45:00 0.3276
1:00:00 0.168
1:15:00 0.252
1:30:00 6.0858
1:45:00 0.336
2:00:00 0.2394
C 0:15:00 0.1638
0:30:00 0.3276
0:45:00 0.336
1:00:00 0.336
1:15:00 0.168
1:30:00 0.2394
1:45:00 0.3402
2:00:00 0.3318
Time on X axis, value on y axis for each type. Please help me.
Upvotes: 0
Views: 101
Reputation: 2149
import matplotlib.pyplot as plot
timestamp_list = ['0:15:00','0:30:00','0:45:00','1:00:00','1:15:00','1:30:00','1:45:00','2:00:00']
a_list = [5.3718, 3.4776, 5.6616, 0.1638, 5.2206, 2.6544, 0.2982, 0.1638]
b_list = [6.8376, .03402, 0.3276, 0.168, 0.252, 6.0858, 0.336, 0.2394]
c_list = [0.1638, 0.3276, 0.336, 0.336, 0.168, 0.2394, 0.3402, 0.3318]
plot.plot(timestamp_list, a_list)
plot.plot(timestamp_list, b_list)
plot.plot(timestamp_list, c_list)
plot.xlabel('Time')
plot.show()
Basically, I am using matplotlib
as the plotting module, you can use pip
to install it if you have not installed it already.
As all of your three types are sharing the same timestamp, so that all we need to do is to put type a, b, c values into their own lists and call pyplot
to do the plot for you.
Upvotes: 1