GithubHelp home page GithubHelp logo

kamaropoulos / covid19py Goto Github PK

View Code? Open in Web Editor NEW
84.0 3.0 58.0 49 KB

A tiny Python package for easy access to up-to-date Coronavirus (COVID-19, SARS-CoV-2) cases data.

Home Page: https://pypi.org/project/COVID19Py/

License: GNU General Public License v3.0

Python 100.00%
coronavirus covid-19 covid19 covid19-data coronavirus-tracking api-wrapper hacktoberfest

covid19py's People

Contributors

allcontributors[bot] avatar bbwanaz avatar jbchouinard avatar jdeweese1 avatar kamaropoulos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

covid19py's Issues

Get Daily Cases

It is annoying to manually calculate the daily cases is it possible to directly fetch them or calculate them in COVID19Py

Fetch the daily cases from the data source. JHU has them in GitHub as daily reports.
Or a function could be added to COVID19Py that calculates the daily cases from the total reported cases upon this day

Count Recovered people

Hello, i noticed, that the count of recovered people is always equally, for the test.
covid19 = COVID19Py.COVID19()
latest = covid19.getLatest()
print(
f"Confirmed case count: {latest['confirmed']}\n"
f"Death count: {latest['deaths']}\n"
f"Recovered count: {latest['recovered']}\n\n")
Result:
1771514 (confirmed)
108503 (deaths)
0 (recovered)

Add support for other data sources

Description
Our API provider has recently added support for pulling data from sources other than John Hopkins University, to now include CSBS. We should also give users of our framework the capability to decide which source they want their app to pull from.

Solution
The solution would be to either

  1. Add an argument to the COVID19 constructor for the data source, and every time _request is called we look up the data source on the object and pass it with the request OR
  2. On each appropriate method, add an optional arg for the data source, and pass that into the _request method in the params

I personally lean towards the first solution, I believe it would be a simpler and cleaner implementation than the latter, see below for my thought.

Code sample

class COVID19(object):
    url = ""
    previousData = None
    latestData = None
    __valid_data_sources = ('jhu', 'csbs')

    def __init__(self, url="https://coronavirus-tracker-api.herokuapp.com", data_source='jhu'):
        self.url = url
        if data_source not in self.__valid_data_sources:
            raise Exception()# TODO fix me with better exception
    def _request(self, endpoint: str, params: dict = None):
        if params is None:
            params = {}
        response = requests.get(self.url + endpoint, {**params, 'source': self.data_source})
        response.raise_for_status()
        return response.json()

@Kamaropoulos, any thoughts?

package not found

When I import COVID19py module and write a code
And trying to execute them it gives me error like no module COVID19py

]

All 'US' locations missing 'Province' data

Executing the following use to return timelines for all locations within the country 'US'.

#get locations data
locations = covid19.getLocationByCountryCode("US", timelines = True)

Now it returns only 'US' totals without the 'province' data...

"[{'coordinates': {'latitude': '37.0902', 'longitude': '-95.7129'},
'country': 'US',
'country_code': 'US',
'id': 225,
'last_updated': '2020-03-24T20:41:02.216348Z',
'latest': {'confirmed': 43847, 'deaths': 557, 'recovered': 0},
'province': '',
'timelines': {'confirmed': {'latest': 43847,
'timeline': {'2020-01-22T00:00:00Z': 1,
'2020-01-23T00:00:00Z': 1,
'2020-01-24T00:00:00Z': 2,...."

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.