0

I'm new to Python so I don't know which is the best method to do the task I have to do.

Basically I've got a Spreadsheet with my data; Date, Timestamp, and 6 columns with different particle counts in 6 different sizes. I have managed to read the sheet using pandas and then plotting it as a line graph with the matplotlib.pyplot library. This is all relatively straight forward.

However, I would like to add more lines to the plot, for each count I would like an average for the past 1000 counts.

I am unsure whether to manipulate the dataset with pandas or if there is a different more efficient way to do this. I read that you can also do this with numpy arrays... But I have no experience with either.

Here is the code I have so far:

import pandas as pd
import matplotlib.pyplot as plt

dataset = "2019-10-09-08_DATA.XLS"

dataset_all = pd.read_excel(dataset, skiprows=6, usecols=(
   "Date", "Time", "0.3um", "0.5um", "1.0um", "2.0um", "5.0um", "10.0um"))

dataset_all.plot()

print(dataset_all)
plt.show()

Here is the link to the Spreadsheet: https://drive.google.com/file/d/1GFU_wwt5KMuLkziQlEyWJMHrkV4Pta3k/view?usp=sharing

  • What do you mean by count? A sample dataset would also be helpful so we can recreate your situation better. – molybdenum42 Oct 29 '19 at 13:45
  • 1
    rolling / moving average? https://stackoverflow.com/questions/40060842/moving-average-pandas – Evan Oct 29 '19 at 13:47
  • @molybdenum42 Its a particle counter that counts 6 different particle sizes. I added a link in the question where you can download the sheet – ToniMahoni101 Oct 29 '19 at 14:16
  • I'm not particularly keen on downloading files from strangers on the internet, but it does sound like @Evan has the right answer for you - that should be able to do what you need. – molybdenum42 Oct 29 '19 at 14:19
  • @molybdenum42 Understandable :)) I'll look into that, cheers! – ToniMahoni101 Oct 29 '19 at 14:24

1 Answers1

0

I downloaded your file and it rendered instantly here (in a not so fast machine). I have much larger files (more than 500mb) I use with pandas. No need for optimize unless you have many many times this size of data.

If it starts to get slow to render the plot, you can also generate a file output like PNG.

staticdev
  • 2,950
  • 8
  • 42
  • 66