AnsweredAssumed Answered

Calculate daily change between unique values

Question asked by sjkidd on May 7, 2020
Latest reply on May 11, 2020 by fallingdog

I am working with COVID19 case data and created a dashboard. I have a Jupyter Notebook inside ArcGIS Pro to process the heath dept.'s CSV file everyday. That said, I am a complete novice with Python and fumbled my way though but got something working.

 

I now have a request to show the daily change in cases from the previous day. The source data table just lists the cumulative cases each day over time and lumps the dates together:

 

ID   Date   FIPS   Cases

1   5/7/20   001   25

2   5/7/20   002   13

3   5/6/20   001   23

4   5/6/20   002   9

5   5/5/20   001   21

6   5/5/20   002   8

7   5/4/20   001   21

8   5/4/20   002   6

 

I would like to add a field where it contains the change in value from the previous day:

 

ID   Date   FIPS   Cases   Difference

1   5/7/20   001   25            2

2   5/6/20   001   23            2

3   5/5/20   001   21            0

4   5/4/20   001   21            0 (because this is the starting value)

5   5/7/20   002   13            4

6   5/6/20   002   9              1

7   5/5/20   002   8              2

8   5/4/20   002   6              0 (start)

 

The goal is a time series chart showing the sum of the daily changes for all FIPS by date (but might need to show them by FIPS as well). I know others are doing it but maybe their source data is supplied that way. 

 

This seems like it should be fairly simple but I don't know where to start. Right now I am downloading the csv, truncating the table in my GDB, then appending the csv data to the table to refresh it every day. I think I need a bit of code to run daily to recalculate the difference after I grab the new day's values. 

 

Appreciate any direction. Thanks!

Outcomes