SHARE
TWEET

Untitled

a guest Jun 25th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from google.cloud import bigquery
  2. client = bigquery.Client()
  3. dataset_ref = client.dataset("chicago_crime", project="bigquery-public-data")
  4. # ...
  5. # API request - fetch the table
  6. # ...
  7. table.schema[:4]
  8.      
  9. [SchemaField('unique_key', 'INTEGER', 'REQUIRED', 'Unique identifier for the record.', ()),
  10.  SchemaField('case_number', 'STRING', 'NULLABLE', 'The Chicago Police Department RD Number (Records Division Number), which is unique to the incident.', ()),
  11.  SchemaField('date', 'TIMESTAMP', 'NULLABLE', 'Date when the incident occurred. this is sometimes a best estimate.', ()),
  12.  SchemaField('block', 'STRING', 'NULLABLE', 'The partially redacted address where the incident occurred, placing it on the same block as the actual address.', ())
  13.      
  14. from operator import itemgetter
  15. fields_list=itemgetter(1,3)(table.schema)
  16. client.list_rows(table, selected_fields=fields_list, max_results=5).to_dataframe()
  17.      
  18. case_number block
  19. 0   JC299491    114XX S CHAMPLAIN AVE
  20. 1   JC273204    053XX N LOWELL AVE
  21.      
  22. fields_list=['case_number', 'block']
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top