Skip to content
Snippets Groups Projects
Commit 46e3de83 authored by CI-bot's avatar CI-bot Committed by renku 0.10.4
Browse files

renku rerun data/covidtracking/states-metadata.json data/covidtracking/states-daily.json

parent 2a900767
No related branches found
No related tags found
1 merge request!389Automatic update - auto-update_2020-12-04_08-06
Pipeline #120108 failed with stages
in 48 minutes and 44 seconds
class: Workflow
cwlVersion: v1.0
hints: []
inputs:
input_1:
default: states-daily.json
streamable: false
type: string
input_2:
default: out_folder
streamable: false
type: string
input_3:
default: data/covidtracking
streamable: false
type: string
input_4:
default:
class: File
path: ../../notebooks/process/download-covidtracking-data.ipynb
streamable: false
type: File
input_5:
default: runs/download-covidtracking-data.runs.ipynb
streamable: false
type: string
input_6:
default: states-metadata.json
streamable: false
type: string
outputs:
output_2:
outputSource: step_2/output_0
streamable: false
type: File
output_3:
outputSource: step_2/output_1
streamable: false
type: Directory
requirements: []
steps:
step_1:
in:
filename: input_1
input_directory: step_2/output_1
out:
- output_file
run:
arguments: []
baseCommand:
- 'true'
class: CommandLineTool
cwlVersion: v1.0
hints: []
inputs:
filename:
default: states-daily.json
streamable: false
type: string
input_directory:
streamable: false
type: Directory
outputs:
output_file:
outputBinding:
glob: $(inputs.filename)
streamable: false
type: File
permanentFailCodes: []
requirements:
- &id001
class: InlineJavascriptRequirement
- &id002
class: InitialWorkDirRequirement
listing: $(inputs.input_directory.listing)
successCodes: []
temporaryFailCodes: []
step_2:
in:
input_1: input_2
input_2: input_3
input_3: input_4
input_4: input_5
out:
- output_0
- output_1
run: a17d560c41a54f5aa307ce5f3c5effe5_papermill.cwl
step_3:
in:
filename: input_6
input_directory: step_2/output_1
out:
- output_file
run:
arguments: []
baseCommand:
- 'true'
class: CommandLineTool
cwlVersion: v1.0
hints: []
inputs:
filename:
default: states-metadata.json
streamable: false
type: string
input_directory:
streamable: false
type: Directory
outputs:
output_file:
outputBinding:
glob: $(inputs.filename)
streamable: false
type: File
permanentFailCodes: []
requirements:
- *id001
- *id002
successCodes: []
temporaryFailCodes: []
source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
%% Cell type:code id: tags:
``` python
import requests
import os
import pandas as pd
```
%% Cell type:code id: tags:parameters
``` python
out_folder = "../data/covidtracking/"
PAPERMILL_OUTPUT_PATH = None
```
%% Cell type:code id: tags:injected-parameters
``` python
# Parameters
PAPERMILL_INPUT_PATH = "/tmp/18hdod4w/notebooks/process/download-covidtracking-data.ipynb"
PAPERMILL_INPUT_PATH = "/tmp/4jh789g5/notebooks/process/download-covidtracking-data.ipynb"
PAPERMILL_OUTPUT_PATH = "runs/download-covidtracking-data.runs.ipynb"
out_folder = "data/covidtracking"
```
%% Cell type:markdown id: tags:
# Download state metadata
Download a dataset of URLs for data for each US state and several territories. See [Google Doc](https://docs.google.com/spreadsheets/d/18oVRrHj3c183mHmq3m89_163yuYltLNlOmPerQ18E8w/htmlview?sle=true).
%% Cell type:code id: tags:
``` python
url = 'http://covidtracking.com/api/states/info'
r = requests.get(url, allow_redirects=True)
states_metadata_json = r.content
```
%% Cell type:code id: tags:
``` python
# save the result
if PAPERMILL_OUTPUT_PATH:
out_path = os.path.join(out_folder, 'states-metadata.json')
with open(out_path, 'wb') as f:
f.write(states_metadata_json)
```
%% Cell type:code id: tags:
``` python
metadata_df = pd.read_json(states_metadata_json)
print(len(metadata_df), "states and territories have metadata")
metadata_df.head(2)
```
%% Output
56 states and territories have metadata
state notes \
0 AK Alaska combines PCR and antigen tests in the t...
1 AL Alabama combines PCR and antigen tests in the ...
covid19Site \
0 http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-...
1 https://alpublichealth.maps.arcgis.com/apps/op...
covid19SiteSecondary \
0 https://experience.arcgis.com/experience/ed1c8...
1 https://alpublichealth.maps.arcgis.com/apps/op...
covid19SiteTertiary \
0 https://alaska-dhss.maps.arcgis.com/apps/opsda...
1 https://services7.arcgis.com/4RQmZZ0yaZkGR1zy/...
covid19SiteQuaternary \
0 https://services1.arcgis.com/WzFsmainVTuD5KML/...
1 None
covid19SiteQuinary twitter \
0 https://services1.arcgis.com/WzFsmainVTuD5KML/... @Alaska_DHSS
1 None @alpublichealth
covid19SiteOld \
0 http://dhss.alaska.gov/dph/Epi/id/Pages/COVID-...
1 http://www.alabamapublichealth.gov/infectiousd...
covidTrackingProjectPreferredTotalTestUnits \
0 Specimens
1 People
covidTrackingProjectPreferredTotalTestField totalTestResultsField \
0 totalTestsViral Total Tests (PCR)
1 totalTestsPeopleViral Total PCR Tests (People)
pui pum name fips
0 All data False Alaska 2
1 No data False Alabama 1
%% Cell type:markdown id: tags:
# Download daily state data
%% Cell type:code id: tags:
``` python
url = 'https://covidtracking.com/api/states/daily'
r = requests.get(url, allow_redirects=True)
states_daily_json = r.content
```
%% Cell type:code id: tags:
``` python
# save the result
if PAPERMILL_OUTPUT_PATH:
out_path = os.path.join(out_folder, 'states-daily.json')
with open(out_path, 'wb') as f:
f.write(states_daily_json)
```
%% Cell type:code id: tags:
``` python
data_df = pd.read_json(states_daily_json)
print(len(data_df), "data points")
data_df.head(2)
```
%% Output
15409 data points
15465 data points
date state positive probableCases negative pending \
0 20201202 AK 32531.0 NaN 992112.0 NaN
1 20201202 AL 256828.0 43656.0 1390351.0 NaN
0 20201203 AK 33291.0 NaN 1007214.0 NaN
1 20201203 AL 260359.0 44421.0 1400010.0 NaN
totalTestResultsSource totalTestResults hospitalizedCurrently \
0 totalTestsViral 1024643.0 164.0
1 totalTestsPeopleViral 1603523.0 1801.0
0 totalTestsViral 1040505.0 157.0
1 totalTestsPeopleViral 1615948.0 1827.0
hospitalizedCumulative ... posNeg deathIncrease hospitalizedIncrease \
0 768.0 ... 1024643 0 19
1 25821.0 ... 1647179 73 211
0 783.0 ... 1040505 8 15
1 26062.0 ... 1660369 65 241
hash commercialScore \
0 a67835c9975e7a741cbe7511d7b8014f238f7381 0
1 4aa82c6006d2babec8c2e4268bc0d73e2681fe76 0
0 2681286b4959bcec2a503789d53119c645f4b0c6 0
1 d333019ec43ddf9c5c4ec262bc5ed78ee214f19b 0
negativeRegularScore negativeScore positiveScore score grade
0 0 0 0 0
1 0 0 0 0
[2 rows x 55 columns]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment