Skip to content

Instantly share code, notes, and snippets.

View sierra073's full-sized avatar
👩‍💻

Sierra sierra073

👩‍💻
View GitHub Profile
@sierra073
sierra073 / NewLaptop.md
Last active November 24, 2020 03:13
Notes for setting up a new Mac for development

Software to Download

Browsers

  • Google Chrome
  • Firefox

Other

  • Slack
  • Spotify
  • Jumpcut or alternative (keeps clipboard history)
  • Set up Mail app or Boxy Suite for gmail accounts
  • OneNote
def distance(origin, destination):
'''Haversine distance function to compute distance between 2 lat/long pairs. source: https://gist.github.com/rochacbruno/2883505'''
lat1, lon1 = origin
lat2, lon2 = destination
radius = 3959 # miles
dlat = math.radians(lat2 - lat1)
dlon = math.radians(lon2 - lon1)
a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) \
* math.cos(math.radians(lat2)) * math.sin(dlon / 2) * math.sin(dlon / 2)
import os
def generate_create_table_statement_from_df(df, schema, tablename, output_path, **kwargs):
'''Function to create a PostgreSQL "create table" statement automatically given a pandas dataframe df.
Other mandatory inputs: schema, tablename, output_path = absolute path to where you want the "create table" sql file to be placed
Optional: primary_key = [list of strings of column name(s) (in order) that define the primary key]'''
headers, type_list = generate_headers(df)
statement = create_table_sql(schema, tablename, headers, type_list, kwargs.get('primary_key', None))
os.chdir(output_path)
import os
import pandas as pd
import numpy as np
from tqdm import tqdm
import concurrent.futures as cf
from itertools import zip_longest
GITHUB = os.environ.get("GITHUB")
facilities = pd.read_csv('../data/raw/facilities.csv')
@sierra073
sierra073 / .block
Created November 6, 2018 00:15
animated donut chart
license: mit
@sierra073
sierra073 / .block
Created November 5, 2018 23:53
animated donut chart
license: mit
@sierra073
sierra073 / .block
Created November 5, 2018 23:44
choropleth map
license: mit
@sierra073
sierra073 / .block
Last active February 28, 2020 02:28
animated bar chart with labels
license: mit