Skip to content
Advertisement

Multiple lines chart from dataframe with looping samples

I have a big dataframe which includes 30 samples, measured one every 6 sec over days. It looks something like this:

DATE_TIME SAMPLE VALUE
2020-12-10 10:52:48 1 3.22
2020-12-10 10:52:54 2 2.93
2020-12-10 10:53:00 3 2.27
2020-12-10 16:27:13 1 1.66
2020-12-10 16:27:19 2 1.15
2020-12-10 16:27:25 3 1.23

I want to plot the time series for each individual sample (multiple line chart). I tried:

JavaScript

But it’s not working, I get a strange figure: bad figure

I also tried making individual dataframes for the samples and it works but I’m sure there must be a more efficient way to do this.

JavaScript

idea of the figure I want

Advertisement

Answer

If you have plot a dataframe with several columns, you get the desired result. You can transform your dataframe to such by groupby or set_index:

JavaScript

or, if you do not have duplicates

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement