Skip to main content

Web Scraper for Sweden COVID19 data.

Project description

Web Scraper of COVID-19 data for Sweden

Python package covid19sweden provides access to mortality and COVID-19 data of Sweden.

The data is scraped from:

Setup and usage

Install from pip with

pip install covid19sweden

Only function currently is death(), fetching the data of deaths. Use it as

import covid19sweden as SWE

data,data2,unknown = SWE.deaths()

Package is regularly updated. Update with

pip install --upgrade covid19sweden

Parametrization

Return value

The first obvious thing is interpretation of return values.

The function returns three values:

  • first return value data is the main return value.
  • second return value data2 is often averaged or total values, where descriptors (age, gender) are marginalized out.
  • third return value unknown is deaths, that were for some reason not assigned to weeks / days, for example when the death date is not known.

To find out interpretation of each value in each parameter configuration, see scb.py in the package source code.

Level

Level is a setting for granularity of data

  1. Country level (default)
  2. State level
  3. Municipality level
import covid19sweden as SWE

# country level
x1a,x1b,x1u = SWE.deaths(level = 1)
# state level
x2a,x2b,x2u = SWE.deaths(level = 2)
# municipality level
x3a,x3b,x3u = SWE.deaths(level = 3)

By default the level is 1. Level settings can be implicitly changed in the function.

Weekly

Weekly is a setting of time axis of the data.

  • True - data are by weeks
  • False - data are by days

Default is False, data by days.

import covid19sweden as SWE

# weekly
xa,xb,xu = SWE.deaths(weekly = True)

Given setting will implicitly change per_gender_age = True, even though default is False. This behavior is described at section Verbose and alt.

Setting of weekly can be also implicitly changed if no data is available for given settings.

Per gender or age

The settings per_gender_age is controlling the deaths to be splitted into groups by gender (M,F) and age groups (mostly 0-64,65-79,80-89,90+).

import covid19sweden as SWE

# weekly
xa,xb,xu = SWE.deaths(per_gender_age = True)

Setting of per_gender_age can be implicitly changed if no data is available for given settings.

Verbose and alt

Not for all the combinations of the parameters the data is available. E.g. for level = 3, only daily data without gender and age distinguishing is available. Hence to minimize error rate, implicit parameter changes are introduced.

If the data for given settings is not available, a set of rules is applied to reach data:

  • if data is available for not per_gender_age, use them
  • if data is available for not weekly, use them
  • if data is available for not per_gender_age, not_weekly, use them

Implicit parameter change is announced on stdout. It can be switched off by setting verbose = False.

Sometimes multiple datasets with slight difference (or two conversions) are available. This is announced on stdout. Choosing an alternative data is done with alt = True.

Commit

With a single call all the data handlers are called and their outputs as well as common input (xlsx file) is stored. Commit is stored directory commit_YYMMDD (in cwd) unless explicitly specified.

import covid19sweden as SWE
SWE.commit() # store all files

Explicit specification of directory is done with

SWE.commit("/var/latest_data")

Function will try to create the folder. It fails on existing files of the same name. Overwriting must be enabled

SWE.commit("/var/latest_data", overwrite = True)

Contribution

Developed by Martin Benes.

Join on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

covid19sweden-0.1.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

covid19sweden-0.1.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file covid19sweden-0.1.1.tar.gz.

File metadata

  • Download URL: covid19sweden-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3rc1

File hashes

Hashes for covid19sweden-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b97b3a5274491212a1cca4c3ac0c1af8d1dbf3847389e9958d76f5921ccd88e8
MD5 d3a2128189669ca63be78b4e3fe0dba2
BLAKE2b-256 3425e081c3fdd8193ffd1a24f59951813e2674726f85b05a5d286acedfcf16ec

See more details on using hashes here.

File details

Details for the file covid19sweden-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: covid19sweden-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3rc1

File hashes

Hashes for covid19sweden-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53cf0b7e75ebce1f764cf06069acce0cb831644d2d1e732a6844f7ffc1d1ee9d
MD5 9511443f53d8ec723ee16e59422a3b22
BLAKE2b-256 b28179ffe7eccdc4243e1c3a8d4f6327cb990414ca5b3ce33dca70fceca601de

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page