Skip to content

PyPI version 0.0.11

Compare
Choose a tag to compare
@krivard krivard released this 12 Feb 23:02
· 2126 commits to main since this release
9496806

This is an update to the PyPI package delphi-epidata, which can be found at https://pypi.org/project/delphi-epidata/.

This version supports submitting many queries simultaneously using aiohttp.

It can be installed like this:

pip install delphi-epidata

Sample usage:

# import
from delphi_epidata import Epidata
from datetime import datetime, timedelta

start = datetime(2020, 9, 8)
dates = [(start + timedelta(days=i)) for i in range(60)]
params = [
    {
        'endpoint': 'covidcast',
        'data_source': 'fb-survey',
        'signals': 'smoothed_wearing_mask',
        'time_type': 'day',
        'geo_type': 'county',
        'geo_value': '*',
        'time_values': d.strftime("%Y%m%d")
    } for d in dates
]

output = Epidata.async_epidata(params, batch_size=10)

Sample output:

[
  (
    {
      "result": 1,
      "epidata": [
        {
          "geo_value": "01000",
          "signal": "smoothed_wearing_mask",
          "time_value": 20200908,
          "direction": null,
          "issue": 20201209,
          "lag": 92,
          "value": 87.8745134,
          "stderr": 1.7062192,
          "sample_size": 366.0096
        },
        ...],
      "message": "success"
    },
    {
      "endpoint": "covidcast",
      "data_source": "fb-survey",
      "signals": "smoothed_wearing_mask",
      "time_type": "day",
      "geo_type": "county",
      "geo_value": "*",
      "time_values": "20200908"
    }
  ),
  (
    {
      "result": 1,
      "epidata": [
        {
          "geo_value": "01000",
          "signal": "smoothed_wearing_mask",
          "time_value": 20200909,
          "direction": null,
          "issue": 20201209,
          "lag": 91,
          "value": 84.1639592,
          "stderr": 1.2342333,
          "sample_size": 874.9399
        },
        ...],
      "message": "success"
    },
    {
      "endpoint": "covidcast",
      "data_source": "fb-survey",
      "signals": "smoothed_wearing_mask",
      "time_type": "day",
      "geo_type": "county",
      "geo_value": "*",
      "time_values": "20200909"
    }
  ),
  ...
]