/* jquery */ /* jquery accordion style*/ /* jquery init */

Astro Pi Data: Python Date Filter

In my previous Astro Pi Data post I showed how to load and process the downloadable Astro Pi Science CSV files using Python.

As I've already mentioned these CSV data files have over 100,000 rows. With this mind let's look at how to extract the data for one particular day.

We're going to start with the Python Basics code from last time, then add a new function and replace the processing loop.

Our function needs to take two parameters: the full list of rows and the date in question. It returned a new list containing only the date-matched rows.

Here's the Python 3 code:

Now we can call this function to populate a list variable with the date-specific data. After this we'll replace the previous row processing loop with one that iterates through the returned list.

Here's the code:

Next time we'll write code to identify interesting days using statistical methods.

Start coding today with my Learn Python on the Raspberry Pi tutorial.

No comments: