Skip to main content

Epidemiological weeks based on the CDC (MMWR) and ISO (WHO) calculation methods.

Project description

A Python package to calculate epidemiological weeks using the CDC (MMWR) and ISO (WHO) calculation methods.

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

Features

  • Accurate and tested calculation.

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

  • Support for both CDC (MMWR) and ISO (WHO) calculation methods.

  • 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 calculation tool that was developed to calculate epidemiological weeks by the CDC method 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.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 argument ‘WHO’ of method parameter 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.0.0.tar.gz (22.1 kB view hashes)

Uploaded Source

Built Distribution

epiweeks-2.0.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

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