This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT * FROM subset | |
| WHERE RAND() < 1e6 / (SELECT COUNT(*) FROM subset) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from IPython.display import HTML, IFrame, display | |
| display(HTML("<style>.container { width:1400px !important; }</style>")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PREFIX dbpedia2: <http://dbpedia.org/property/> | |
| PREFIX dbo: <http://dbpedia.org/ontology/> | |
| PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> | |
| SELECT * | |
| WHERE { | |
| ?county rdf:type yago:County108546183 . | |
| ?county dbo:country dbr:United_States. | |
| ?county dbo:state ?state. | |
| ?county rdfs:label ?county_label. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE TABLE `uc-prox-core-dev.z_jan_retained.adjacent_tracts` AS | |
| WITH adjacent_tracts AS ( | |
| SELECT a.fips, b.fips as fips_adjacent, a.state_name, b.state_name as state_name_adjacent, a.county_name, b.county_name as county_name_adjacent, a.geog, b.geog as geog_adjacent, | |
| FROM `uc-atlas.maps_us.census_tracts` a, `uc-atlas.maps_us.census_tracts` b | |
| WHERE ST_INTERSECTS(ST_BUFFER(a.geog, 25), b.geog) | |
| ) | |
| SELECT * FROM adjacent_tracts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from IPython.display import Javascript # Restrict height of output cell. | |
| display(Javascript('''google.colab.output.setIframeHeight(0, true, {maxHeight: 300})''')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH osm AS ( | |
| SELECT | |
| layer_code, | |
| layer_class, | |
| layer_name, | |
| gdal_type as geography_type, | |
| osm_id, | |
| CASE | |
| WHEN (tags.key = 'name') THEN tags.value | |
| ELSE '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH daily AS ( | |
| SELECT | |
| local_event_date, | |
| venue_type, | |
| SUM(device_count) device_count, | |
| SUM(person_count) person_count, | |
| FROM `uc-prox-core-dev.international_metrics.traffic_trends` | |
| GROUP BY local_event_date, venue_type | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dict_filter = lambda x, y: dict([ (i,x[i]) for i in x if i in set(y) ]) | |
| large_dict = {"a":1,"b":2,"c":3,"d":4} | |
| keys_to_remove = ("c","d") | |
| updated_dict = dict_filter(large_dict, keys_to_remove) | |
| print(updated_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import importlib | |
| importlib.reload(scale_by_scale_optim) | |
| from utils import scale_by_scale_optim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_accuracy(series, recovered_series): | |
| """Compare a simulated and recovered series in terms of overall label accuracy. | |
| Input | |
| ----- | |
| series : list of lists | |
| recovered_series : list of lists | |
| Output | |
| ------ |
NewerOlder