Tracking Virus Trends With Wastewater Data

Terrific Physics
37 followers
1 Video View·Jun 12, 2026
This video shows you how to analyze COVID-19 wastewater data. Written instructions and Python notebook are available on the Science Buddies website: https://www.sciencebuddies.org/scienc...
…
AI Generated·May contain errors
Video Summary
AI GeneratedThis tutorial demonstrates how to use wastewater surveillance data to track COVID-19 trends. By analyzing PCR concentration levels of SARS-CoV-2 viral RNA in sewage, users can identify infection hotspots and outbreak trends. The guide walks through a Python-based project using Google Colab to compare state-level and county-level data against national averages.
Have you ever wanted to know where the hot spots of infection are or see how viruses spread?
In this tutorial, I'm going to show you how wastewater data can be used to study COVID-19
trends over time. The main measurement we'll be using is the PCR concentration level,
which tells us how much SARS-CoV-2 viral RNA was found in a wastewater sample.
Wastewater surveillance is useful because people can shed the virus into sewage even if they have
never taken an official COVID test. The CDC describes wastewater monitoring as a public
health tool that can help identify outbreak trends and complement other surveillance data.
In this project, we'll be comparing COVID-19 wastewater data from a selected state and
counties to national data to identify similarities, differences, and trends over time.
To get started on the project page, you'll want to scroll down to the
setting up the Google Colab environment section. You'll want to download the COVID
wastewater Python notebook as well as the wastewater data from the CDC website.
To download the wastewater data, you can click on this link. This will take you to the official CDC
website and to download this data, all you need to do is click export over here. Make sure it is in
CSV format and then download it. The last file you want to download is the uscounties.csv file.
Then on your my drive, upload all three files and make sure to rename the CDC data to simply
wastewater.csv. You'll open the notebook. All you need to do is double click on the file.
If you've never used Google Colab before, Google Colab is a platform where you can write,
run, and share code. To run the code block, all you need to do is click on this play button here.
You could also click on the code block and hold ctrl enter or command enter if you're on a MacBook.
You can tell a code block has been run by the output here or by the green check mark here.
To add a code block, you can click on this button over here and to delete it, you can click on the
trash icon to the right of each cell. Now let's get started with the project. We'll first start
with importing the libraries that we'll be needing for this project and the reason we do that is so
that we can use functions that other people have already created. All you need to do to import the
library is to run this code block and the second code block will allow the notebook to access the
CSV file that you uploaded earlier. When this pop-up shows up, remember to allow it to connect
to your Google Drive. Now we'll load our data into a pandas data frame and all you need to do to do
that is run this code block. Now we can see the data populate here and it includes a lot of columns
but don't worry, we'll only be focusing on a few. This next code block will print the amount of
data points available for each state. This list will be in order from the most to the least amount
of data. When choosing the state you want to focus on, consider picking one with more data. The next
code block will show you the amount of years available for each state and when picking the
state that you want to focus on, try to pick the state with more years available rather than less.
To make it a little bit easier to pick, this last code block will sort by the number of years
available and the number of data rows. Next, we'll define the state to filter by so I will pick
Pennsylvania and the state abbreviation for Pennsylvania is PA so I'll type that in and then
run this code block and then we'll see the same data frame printed again and this time with only
Pennsylvania. Then we'll reduce the columns so that we can focus on the ones that we'll be using
for this project and all you need to do to do that is run this code block. We can now see that
the data frame will have six columns instead of 38. After code block 2b, the other code blocks from 2c
and to 2f are primarily steps that we do to make it easier for our code to plot our data on a map
and of course you can look more carefully at this code and try to understand it but that's not the
focus of this project so you can just run all the code blocks through like this. Now our data is ready to be
displayed on a map. In this section, the first code block will define a function that displays the
COVID-19 PCR target concentrations from wastewater levels on a map of the state that you have
selected so all you need to do to use this function is run it. The second code block is another function
which will display the average PCR target concentration nationwide and for the state
given a year so all you need to do again is to run this code block. Now this code block will use the
function from the first one to create a map and all you need to do is define the year and the state
you want to create the map for so this means I'll be creating the map for 2022 for the state
Pennsylvania and if you just run this code block you will now see a map of the state that you
picked and these are the PCR target average concentration for that year. You can see that
in some areas they had higher concentration than others and this could be caused by multiple
different factors. There will be a list of questions that you can go through on the project page.
Now let's generate a map of a different year. Here I'll change the year to 2023 and then we'll run
this code block. We can see that in the year 2023 there is much less of the PCR concentration in the
wastewater. You can keep changing the year to see how the COVID levels in the wastewater have changed
over time. Just remember that some states do not have all years so if you try to add in 2021
for Pennsylvania for example it will show nothing because there is no data collected for that year.
Now we'll compare our state data to national data so again we'll check the year 2022 for the state
Pennsylvania and we'll run this first code block. We can see that in 2022 the average concentration
for Pennsylvania is about 1 million and nationwide is about 720,000. Of course there are many
factors that could contribute to why your state might have higher or lower concentration than the
nationwide average and that could include factors as simple as your state being more or less densely
populated than the rest of the U.S. Let's compare another year which is 2023 with the same state
Pennsylvania. This time we can see that the average PCR target concentration for Pennsylvania
is a lot closer to the nationwide average. Now let's review some county data. This code block
will display the counties in the state that you have selected so all you need to do to see that
is to run this code block. Here we can see the list of the counties as well as their FIPS number
and the years for which they have collected data. This next function will print the yearly average
PCR concentration for a given county so just run this code block. Now let's use the helper
function from code block 4b and I will pick this county which corresponds to Allegheny county
in Pennsylvania and just run this code block. Here you can see the PCR target concentrations for
this county printed for every year for which the data is available. You can see that for
this county the target average concentration has decreased over time. This next analysis
is optional but if you would like to see the concentration bar graph for the county that you
have picked you can again input the county FIPS number here and then run this code block and you
can see a bar graph. And with that we have reached the end of this code demonstration.
For more fun science projects check out our YouTube channel.
