How to use read_gbq or other bq in IPython to access datasets hosted in BigQuery

I am using the iPython notebook to read the Google BigQuery public dataset for natality I have done the installation for the google-api easy_install --upgrade google-api-python-client.

However it still does not detect the installed API

Anyone has a iPython notebook to share on accessing the public dataset and loading it into a dataframe in iPython.

import pandas as pd
projectid = "xxxx"
data_frame = pd.read_gbq('SELECT * FROM xxxx', project_id = projectid)

    303     if not _GOOGLE_API_CLIENT_INSTALLED:
--> 304         raise ImportError('Could not import Google API Client.')
    305 
    306     if not _GOOGLE_FLAGS_INSTALLED:

ImportError: Could not import Google API Client

I have shared the iPython Notebook used at http://nbviewer.ipython.org/urls/dl.dropbox.com/s/d77u2xarscagw0b/BigQuery_Trial8.ipynb?dl=0

Additional info: I am running on a server with a docker instance used for the iPython server. I have run the curl https://sdk.cloud.google.com | bash installation on the linux server

I have tried to run some of the shared notebooks nbviewer.ipython.org/gist/fhoffa/6459195 or nbviewer.ipython.org/gist/fhoffa/6472099 However I also get ImportError: No module named bq

I suspect it is a simple case of missing dependencies. Anyone who has clues, help welcome

Upvotes: 3

Views: 2341

Answers (2)

Roman
Roman

Reputation: 9441

Make sure your Pandas is version 0.17 or higher:

pip install -U pandas

You can check with:

import pandas as pd
pd.__version__

Upvotes: 0

wizmer
wizmer

Reputation: 930

As I just said it here: https://stackoverflow.com/a/31708375/2533394 I solved the problem with this:

pip install --force-reinstall uritemplate.py

Upvotes: 1

Related Questions