GithubHelp home page GithubHelp logo

datachile-python-client's Introduction

DataChile Python Client

DataChile Python Client is a Python 3 library to access the DataChile API. This library enables you to use public data from differents sources in your Python applications.

Install

Install from PyPI, using pip:

pip install datachile

Simple Demo

Interact with the API:

  • Get all datasets availables in DataChile
from datachile import ChileCube

client = ChileCube()
query = client.get_cubes()

print(query)
  • Get drilldowns availables from "Election Participation" dataset.
from datachile import ChileCube

client = ChileCube()
cube = "election_participation"

dd = client.get_drilldowns(cube)
ms = client.get_measures(cube)

print(dd)
print(ms)
  • Get exports from Chile in 2012-2014, divided in Year and Destination Country
from datachile import ChileCube

client = ChileCube()

query = client.get(
    "exports", 
    {
        "drilldowns": [
            ["Date", "Year"],
            ["Destination Country", "Country", "Country"]
        ],
        "measures": ["FOB US"],
        "cuts": [
            {
                "drilldown": ["Date", "Year"],
                "values": [2012, 2013, 2014]
            }
        ],
        "parents": True
    }
)

print(query)

Documentation

Please refer to our Wiki documentation for more information or Datachile API Documentation Website.

Development

Contributing

Long-term discussion and bug reports are maintained via GitHub Issues. Code review is done via GitHub Pull Requests.

License

The MIT License (MIT)

Copyright (c) 2018 Carlos Navarrete & Datawheel LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

datachile-python-client's People

Contributors

cnavarretel avatar cnavarreteliz avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datachile-python-client's Issues

Mondrian problem when installing datachile thru pip

I keep getting this error when trying to install:

Could not find a version that satisfies the requirement mondrian_rest==0.1 (from datachile) (from versions: )
No matching distribution found for mondrian_rest==0.1 (from datachile)

can anyone help?

mondrian_rest trouble

pip install datachile fails:

Collecting mondrian_rest==0.1 (from datachile)
Could not find a version that satisfies the requirement mondrian_rest==0.1 (from datachile) (from versions: )
No matching distribution found for mondrian_rest==0.1 (from datachile)

pandas format (as default one day)

Most of the time, right after pulling data as the result of a query, most people will create a pandas.DataFrame. Couldn't we provide an option (df=True) as openaq does? It saves a lot of time AND points people to the direction of pandas, which would encourage plotting, quick transition to DBs, excel, etc.

Test throws error

when I run test/_get.py, I get
Traceback (most recent call last): File "_get.py", line 21, in <module> "parents": True File "...python3.6/site-packages/datachile/chilecube.py", line 110, in get q = agg.tidy File "...python3.6/site-packages/mondrian_rest/aggregation.py", line 94, in tidy measures = data['axes'][0]['members'] KeyError: 'axes

ConnectionError. I think that API_BASE is wrong

Hi! Today I tried to use this api client, but it got the following error with the example code:

from datachile import ChileCube

client = ChileCube()
query = client.get_cubes()

print(query)

ConnectionError: HTTPSConnectionPool(host='chilecube.datawheel.us', port=443): Max retries exceeded with url: /cubes (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f58b0d8c7f0>: Failed to establish a new connection: [Errno 111] Connection refused'))

I think that API_BASE in datachile/chilecube.py is wrong. Actually it is API_BASE = "https://chilecube.datawheel.us", but in datachile api webpage (https://es.datachile.io/about/api) the url base is https://chilecube.datachile.io

My setup:
Ubuntu 18.04 LTS with conda environment (python 3.7).

PD: Sorry for my english, it isn't my primary language.

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.