Skip to content

Instantly share code, notes, and snippets.

@michellemho
michellemho / s_join_experiments.ipynb
Created June 16, 2019 22:38
spatial join experiments
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# METHOD 1: INDEX ON GRID, LOOP THROUGH ISOCHRONES
# Add columns of zero and empty dictionaries
grid_copy['count_unique'] = 0
grid_copy['sum_times'] = 0
empty = {key: np.inf for key in isochrones.origin.unique()}
grid_copy['unique_ids'] = [[] for i in range(len(grid_copy))]
grid_copy['min_times'] = [{key: np.inf for key in isochrones.origin.unique()} for i in range(len(grid_copy))]
spatial_index = grid_copy.sindex
for idx, isochrone in isochrones.iterrows():
possible_matches_index = list(spatial_index.intersection(isochrone.geometry.bounds))
from faker import Faker
fake = Faker()
print(fake.name())
print(fake.company())
print(fake.address())
import numpy as np
from datetime import datetime, timedelta
start_date=datetime(2017,1,1)
end_date=datetime.today()
spring_peak = datetime(2017,4,5)
fall_peak = datetime(2017,9,15)
num_visits = 10000
@michellemho
michellemho / fake_911_calls.ipynb
Created September 17, 2018 21:48
Generating Emergency Call Data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@michellemho
michellemho / tictactoe.py
Created September 7, 2018 21:58
let's play tic tac toe!
def play_tic_tac_toe():
print("""Let's play tictactoe! The board looks like
# 1 2 3
# A A1 A2 A3
# B B1 B2 B3
# C C1 C2 C3""")
board = [('A', 1), ('A', 2), ('A', 3),
('B', 1), ('B', 2), ('B', 3),
('C', 1), ('C', 2), ('C', 3)]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@michellemho
michellemho / index.html
Last active February 11, 2018 18:41
Flotsam+Jetsam
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flotsam and Jetsam</title>
<!-- Include Leaflet 1.2.0 Library -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<!-- Fonts -->
<link href='https://fonts.googleapis.com/css?family=Oswald:300,400,600,700' rel='stylesheet' type='text/css'>