from google.cloud import bigquery client = bigquery.Client.from_service_account_json( '/home/makarov/notebooks/my-bq-project-225910-6e534ba48078.json') sql = ''' SELECT DATE(creation_date) as date, DATE_TRUNC(DATE(creation_date), MONTH) as month, DATE_TRUNC(DATE(creation_date), YEAR) as year, COUNT(id) as questions FROM `bigquery-public-data.stackoverflow.posts_questions` WHERE tags LIKE '%pandas%' GROUP BY date, month, year ''' project_id = 'my-bq-project-225910' df2 = client.query(sql, project=project_id).to_dataframe() display(df2.head(5))