Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from google.cloud import bigquery
- client = bigquery.Client()
- dataset_ref = client.dataset("chicago_crime", project="bigquery-public-data")
- # ...
- # API request - fetch the table
- # ...
- table.schema[:4]
- [SchemaField('unique_key', 'INTEGER', 'REQUIRED', 'Unique identifier for the record.', ()),
- SchemaField('case_number', 'STRING', 'NULLABLE', 'The Chicago Police Department RD Number (Records Division Number), which is unique to the incident.', ()),
- SchemaField('date', 'TIMESTAMP', 'NULLABLE', 'Date when the incident occurred. this is sometimes a best estimate.', ()),
- SchemaField('block', 'STRING', 'NULLABLE', 'The partially redacted address where the incident occurred, placing it on the same block as the actual address.', ())
- from operator import itemgetter
- fields_list=itemgetter(1,3)(table.schema)
- client.list_rows(table, selected_fields=fields_list, max_results=5).to_dataframe()
- case_number block
- 0 JC299491 114XX S CHAMPLAIN AVE
- 1 JC273204 053XX N LOWELL AVE
- fields_list=['case_number', 'block']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement