Skip to main content

A library to access Data Commons Python API.

Project description

Data Commons Python API

This is a Python library for accessing data in the Data Commons Graph.

See also: Data Commons Pandas API.

To get started, install this package from pip.

pip install datacommons

Once the package is installed, import datacommons.

import datacommons as dc

If you would like to provide an API key, follow the steps in Setting up access to the Data Commons API, add the following line to your code:

dc.set_api_key('YOUR-API-KEY')

Data Commons does not charge users, but uses the API key for understanding API usage.

For more detail on getting started with the API, please visit our API Overview.

When you are ready to use the API, you can refer to datacommons/examples for examples on how to use this package to perform various tasks. More tutorials and documentation can be found on our tutorials page!

About Data Commons

Data Commons is an open knowledge repository that provides a unified view across multiple public data sets and statistics. You can view what datasets are currently ingested and browse the graph using our browser.

License

Apache 2.0

Development

The Python API currently supports python>=2.7.

To test, run:

$ ./run_tests_local.sh

To debug the continuous integration tests, run:

$ cloud-build-local --config=cloudbuild.yaml --dryrun=false .

Both commands will run the same set of tests.

To run the examples:

$ python -m datacommons.examples.XXX

where XXX is the module you want to run.

Release

Note: Always release datacommons_pandas when datacommons is released.

If this is your first time releasing to PyPI, please review the PyPI guide starting from the setup section.

Release to Test PyPI

  1. In setup_datacommons.py and setup_datacommons_pandas.py:
    • Append "-USERNAME" to the package "NAME". For example, NAME = 'foo_package-janedoe123'.
    • Increment the "VERSION" codes to something that has not been used in your test project. This will not affect the production PyPI versioning.
  2. Build the dists:
    rm dist/*
    python3 -m pip install --user --upgrade setuptools wheel
    python3 setup_datacommons.py sdist bdist_wheel
    python3 setup_datacommons_pandas.py sdist bdist_wheel
    
  3. Release the dists to TestPyPI:
    python3 -m pip install --user --upgrade twine
    python3 -m twine upload --repository testpypi dist/*
    

Release to Production PyPI

  1. In setup_datacommons.py and setup_datacommons_pandas.py:
    • Revert the package name to datacommons and datacommons_pandas
    • Update and double check "VERSION"
  2. Update CHANGELOG.md and datacommons_pandas/CHANGELOG.md
  3. Build the dists:
    rm dist/*
    python3 -m pip install --user --upgrade setuptools wheel
    python3 setup_datacommons.py sdist bdist_wheel
    python3 setup_datacommons_pandas.py sdist bdist_wheel
    
  4. Release the dists to PyPI:
    python3 -m pip install --user --upgrade twine
    twine upload dist/*
    

Support

For general questions or issues about the API, please open an issue on our issues page. For all other questions, please send an email to support@datacommons.org.

Note - This is not an officially supported Google product.

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

datacommons-1.4.3.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

datacommons-1.4.3-py3-none-any.whl (46.5 kB view details)

Uploaded Python 3

File details

Details for the file datacommons-1.4.3.tar.gz.

File metadata

  • Download URL: datacommons-1.4.3.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for datacommons-1.4.3.tar.gz
Algorithm Hash digest
SHA256 4940a6ccdca7e571d5d4e094acab222adb967d83ca93877354b8396924e79d26
MD5 38e64abd1ae15421501bb78905f8cad0
BLAKE2b-256 256d4fc9b08a784a542c3a7b5ecbc7f856ba2fdbe86ea236ffefc11dd976ecda

See more details on using hashes here.

File details

Details for the file datacommons-1.4.3-py3-none-any.whl.

File metadata

  • Download URL: datacommons-1.4.3-py3-none-any.whl
  • Upload date:
  • Size: 46.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for datacommons-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fd75f626b45f717164f32bf0cf0a76775012917d46c2a75cbe94c9d7f8d14926
MD5 a0a0ffc5c39843b542aa4a3f3fad9c39
BLAKE2b-256 b93415b15dbe8bafcfcefc61543088ba95a1ed617f3e635a840851dd7c51cddc

See more details on using hashes here.

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