Coder Social home page Coder Social logo

pygodata's Introduction

godata-pandas

A Python/Pandas interface for GoData

Setup

Editable install from source

If you want to be able to make changes to the package and maybe make a pull request:

pip install -r requirements.txt
./setup.py develop

Example usage

import datetime
from pygodata.api import GoDataAPI
from pygodata.util import dt_to_iso, explode_questionnaire, explode_address

api = GoDataAPI(
   api_url='https://your-godata-instance.org/api/',
   outbreak_id='9674db58-6ed9-496a-aaf8-96006c6ef3c0',
   username='[email protected]',
   password='12345',
)

# Download cases, contacts, events, and relationships from the past week
end_date = datetime.datetime.now().replace(microsecond=0)
start_date = end_date - datetime.timedelta(7)

params = {
    "where" : {
        "updatedAt": {
        "between": [
            dt_to_iso(start_date),
            dt_to_iso(end_date)
        ]
        }
    },
}

api.login()  # Get a new token. May need to be called again when the token is not valid anymore.
cases = api.get_items("cases", params=params)
contacts = api.get_items("contacts", params=params)
events = api.get_items("events", params=params)
relationships = api.get_items("relationships", params=params)


# Extract questionnaire answers as separate columns
cases = explode_questionnaire(cases)
contacts = explode_questionnaire(contacts)

# Extract address fields as separate columns (Assuming each person has no more than one address)
cases = explode_address(cases)
contacts = explode_address(contacts)

pygodata's People

Contributors

ssidorenko avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.