layout | title | nav_order | parent | has_children |
---|---|---|---|---|
default |
Python |
40 |
API |
true |
The Data Commons Python API is a Python library that enables developers to programmatically access nodes in the Data Commons knowledge graph. This package allows users to explore the structure of the graph, integrate statistics from the graph into data analysis workflows and much more.
Note: The Python API only supports V1 of the REST APIs.
Before proceeding, make sure you have followed the setup instructions below.
This procedure uses a Python virtual environment as recommended by Google Cloud Setting up a Python development environment{: target="_blank"}.
- If not done already, install python3 and pip3. See Installing Python for procedures.
- Go to your project directory and create a virtual environment using venv, as described in Using venv to isolate dependencies{: target="_blank"}.
- Install the the
datacommons
package:
$ pip install datacommons
You are ready to go! You can view our tutorials on how to use the API to perform certain tasks using Google Colab{: target="_blank"}, or refer to pages in the navigation bar for detailed information about all the methods available.
The pages in this site demonstrate running Python methods interactively from the Bash shell. To use this facility, be sure to import the datacommons
package:
From your virtual environment, run:
python3
>>> import datacommons
>>>