GithubHelp home page GithubHelp logo

loniasgr / covid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nf1s/covid

0.0 1.0 0.0 2.43 MB

Python package to fetch information regarding the novel corona virus provided by Johns Hopkins university and worldometers.info

Home Page: https://ahmednafies.github.io/covid/

License: MIT License

Python 98.82% Makefile 1.18%

covid's Introduction

Covid

CircleCI codecov GitHub Pipenv locked Python version Downloads GitHub

Description

Python package to get information regarding the novel corona virus provided by Johns Hopkins university and worldometers.info

Full Documentation can be found here

corona.jpeg

Requirements

python >= 3.6

How to install

pip install covid

Dependencies

pydantic
requests

How to use

John Hopkins University API

john_hopkins

Get All Data

from covid import Covid

covid = Covid()
covid.get_data()

Result

[
    {
        'id': '53',
        'country': 'China',
        'confirmed': 81020,
        'active': 9960,
        'deaths': 3217,
        'recovered': 67843,
        'latitude': 30.5928,
        'longitude': 114.3055,
        'last_update': 1584097775000
    },
    {
        'id': '115',
        'country': 'Italy',
        'confirmed': 24747,
        'active': 20603,
        'deaths': 1809,
        'recovered': 2335,
        'latitude': 41.8719,
        'longitude': 12.5674,
        'last_update': 1584318130000
    },
    ...
]

List Countries

This comes in handy when you need to know the available names of countries when using get_status_by_country_name, eg. "The Republic of Moldova" or just "Moldova" So use this when you need to know the country exact name that you can use.

countries = covid.list_countries()

Result

[
    {'id': '53', 'country': 'China'},
    {'id': '115', 'country': 'Italy'}
    ...
]

Get Status By Country ID

italy_cases = covid.get_status_by_country_id(115)

Result

{
    'id': '115',
    'country': 'Italy',
    'confirmed': 24747,
    'active': 20603,
    'deaths': 1809,
    'recovered': 2335,
    'latitude': 41.8719,
    'longitude': 12.5674,
    'last_update': 1584318130000
}

Get Status By Country Name

italy_cases = covid.get_status_by_country_name("italy")

Result

{
    'id': '115',
    'country': 'Italy',
    'confirmed': 24747,
    'active': 20603,
    'deaths': 1809,
    'recovered': 2335,
    'latitude': 41.8719,
    'longitude': 12.5674,
    'last_update': 1584318130000
}

Get Total Confirmed cases

confirmed = covid.get_total_confirmed_cases()

Get Total Deaths

deaths = covid.get_total_deaths()

Getting data from Worldometers.info

worldometers

covid = Covid(source="worldometers")

Get Data

covid.get_data()

Result

[
    {
        'country': 'USA',
        'confirmed': 311637,
        'new_cases': 280,
        'deaths': 8454,
        'recovered': 14828,
        'active': 288355,
        'critical': 8206,
        'new_deaths': 2,
        'total_tests': 1656897,
        'total_tests_per_million': Decimal('0'),
        'total_cases_per_million': Decimal('941'),
        'total_deaths_per_million': Decimal('26')
    },
    {
        'active': 1376,
        'confirmed': 81669,
        'country': 'China',
        'critical': 295,
        'deaths': 3329,
        'new_cases': 30,
        'new_deaths': 3,
        'recovered': 76964,
        'total_cases_per_million': Decimal('57'),
        'total_deaths_per_million': Decimal('2'),
        'total_tests': 0,
        'total_tests_per_million': Decimal('0')
    }
    ...
]

Get Status By Country Name

covid.get_status_by_country_name("italy")

Result

{
    'active': 88274,
    'confirmed': 124632,
    'country': 'Italy',
    'critical': 3994,
    'deaths': 15362,
    'new_cases': 0,
    'new_deaths': 0,
    'recovered': 20996,
    'total_cases_per_million': Decimal('2061'),
    'total_deaths_per_million': Decimal('254'),
    'total_tests': 657224,
    'total_tests_per_million': Decimal('0')
 }

List Countries

countries = covid.list_countries()

Result

[
    'china',
    'italy',
    'usa',
    'spain',
    'germany',
...
]

Get Total Active cases

active = covid.get_total_active_cases()

Get Total Confirmed cases

confirmed = covid.get_total_confirmed_cases()

Get Total Recovered cases

recovered = covid.get_total_recovered()

Get Total Deaths

deaths = covid.get_total_deaths()

CLI 2.0 (New)

covid --help

Get all data

John Hopkins source (default)

covid

or

covid -s john_hopkins

Worldometers source

covid -s worldometers

List Countries

This comes in handy when you need to know the available names of countries when using covid -s 'source' -c 'country_name', eg. "The Republic of Moldova" or just "Moldova" So use this when you need to know the country exact name that you can use.

covid -s worldometers --list-countries

Get Status By Country Name

covid -s worldometers -c sweden

Get Total Active cases

covid -s worldometers -o active

Get Total Confirmed cases

covid -s worldometers -o confirmed

Get Total Recovered cases

covid -s worldometers -o recovered

Get Total Deaths

covid -s worldometers -o deaths

covid's People

Contributors

nf1s avatar hellosaumil avatar loniasgr avatar nkitanov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.