You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use [pandas.io.gbq](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_gbq.html#pandas.read_gbq)
First you will need to pip install: pip install --upgrade google-api-python-client
Here is a working query:
# load keys; requires you to be registeredkeys=json.load(open('/Users/linwood/Desktop/keysforapps/apikeys.txt'))
# setup google creds; not sure if this is required yet; but you need to do it once to authorize the api from your python ecosystemfromapiclient.discoveryimportbuildservice=build('bigquery', 'v2', developerKey=keys['google']['apikey']+"2")
# load query in proper SQL syntax as stringfrompandas.ioimportgbqq="""SELECT MonthYear,count(*)c,count(IF(Actor1Code LIKE 'MUS',1,null)) c_upFROM [gdelt-bq.full.events] WHERE EventRootCode = '19'GROUP BY MonthYear ORDER BY MonthYear;"""# run the querydf=gbq.read_gbq(q, project_id=<projectid>)
:[out]
Requestingquery... ok.
Queryrunning...
Querydone.
Cachehit.
Retrievingresults...
Got461rows.
Totaltimetaken0.75s.
Finishedat2017-05-3010:26:21
The text was updated successfully, but these errors were encountered:
Use [
pandas.io.gbq]
(http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_gbq.html#pandas.read_gbq)First you will need to pip install:
pip install --upgrade google-api-python-client
Here is a working query:
The text was updated successfully, but these errors were encountered: