Skip to main content

Epidemiological weeks based on the CDC (MMWR) and ISO week numbering systems.

Project description

A Python package to calculate epidemiological weeks using the CDC (MMWR) and ISO week numbering systems.

Build Status Coverage Status Docs Status Python version support PyPI Package version License

Features

  • Support for both the CDC (MMWR) and ISO week numbering systems.

  • Accurate and tested calculations.

  • Intuitive, clean, and easy-to-use interface.

  • Calculation of start and end dates of week.

  • Iteration of year’s weeks or week’s dates.

  • Rich comparison between weeks.

  • Logical operations for weeks (addition, subtraction and containment).

  • Validation of input data.

  • Works on Python 3.6+ with zero dependencies.

  • Thoroughly tested on all supported python versions.

Installation

$ pip install -U epiweeks

Basic Usage

from epiweeks import Week, Year

week = Week(2019, 1)
print(week.enddate())
# 2019-01-05

for week in Year(2019).iterweeks():
    print(week.enddate())
# 2019-01-05
# 2019-01-12
# ...
# 2019-12-21
# 2019-12-28

Online Tool

The following is a simple online tool that was developed to calculate epidemiological weeks (CDC system only) using the latest version of this package:

https://www.dralshehri.com/epiweeks/

Documentation

Please see https://epiweeks.readthedocs.io/ for full documentation of this package, including overview, more usage examples and API reference.

Contributing

Contributions are welcome! See CONTRIBUTING.rst for more info.

Authors

The main author is Mohammed Alshehri — @dralshehri.

License

This package is distributed under an MIT license. See LICENSE.

Change Log

2.1.0

  • Changed the keyword argument method, which sets how the weeks are numbered, to system for better clarity and intuitive usage.

  • Updated documentation and unit tests.

  • Other minor fixes and enhancements.

2.0.0

  • Dropped support for Python 3.5.

  • Added fromstring() classmethod to allow constructing the Week object from a formatted string, for example ‘2019W08’ or ‘201908’.

  • Added cdcformat() method to return a formatted string like the one used by US CDC for epi weeks, for example for week 8 of 2019 it returns ‘201908’.

  • Added daydate() method to return the date of specific weekday for a week.

  • Changed the optional value ‘WHO’ of the keyword argument method to ‘ISO’.

  • Changed the fromdate() classmethod of Week object to accept a date object as an argument instead of year, month, and day.

  • Made the Week and Year objects hashable.

  • Improved rich comparison methods.

  • Improved input data validation.

  • Updated and improved documentation examples.

  • Updated unit tests.

  • Other minor fixes and enhancements.

1.0.0

  • First release.

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

epiweeks-2.1.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

epiweeks-2.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file epiweeks-2.1.0.tar.gz.

File metadata

  • Download URL: epiweeks-2.1.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for epiweeks-2.1.0.tar.gz
Algorithm Hash digest
SHA256 b21dda3d35dff1c9e08fc53db0500b6d7399f627f632e3ee4219d13b73095202
MD5 2fa9101b1b5382fcae4914518ccdde93
BLAKE2b-256 1c38e2ee3a37618bf0d7c7a6897b1ad7740959096522689f90575cb7dd438d98

See more details on using hashes here.

File details

Details for the file epiweeks-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: epiweeks-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for epiweeks-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4358da52032b088924ed87eb22c36b52013d600115bd2d02e0c2ad091eb24dd7
MD5 23b86654f87741f9ad242945bb2b7a3f
BLAKE2b-256 dafe8205d596cd3c78cd632c510cfc29ae8713a146a650c2289ccc378fdd7a00

See more details on using hashes here.

Supported by

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