Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
x1 = np.linspace(-0.5, 1.25, num=100) | |
x2 = np.linspace(0, 2, num=100) | |
def y1(x): | |
y = -2 * x**3 + 1.5 * x ** 2 + x | |
return y[np.argmax(y <0):] | |
def y2(x): | |
return 1 / (1 + np.exp(-5 * x + 4)) |
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
"""Really simple example of reading aws Key and Secret from credentials file. """ | |
import os | |
from ConfigParser import SafeConfigParser # Python2 | |
def main(profile="default"): | |
config = SafeConfigParser() | |
config.read(os.path.join(os.getenv("HOME"), ".aws/credentials")) | |
secret = config.get(profile, "aws_secret_access_key") |
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
x = pd.DataFrame({"Date": np.repeat(pd.date_range("2015-01-01", "2015-01-04"), 2), | |
"Class": [1, 2, 1, 2, 1, 2, 1, 2], | |
"Value": np.random.random(size=8)}) | |
p1 = pd.pivot_table(x, index="Date", columns="Class") | |
p2 = pd.pivot_table(x, index="Date", columns="Class", values="Value") | |
p1 | |
# Value | |
# Class 1 2 |
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 X as ( | |
-- select STRUCT<x int64, y string>(1, 'a') as R | |
select * | |
-- from unnest(split("I am the bad man, I am the bad man", " ")) as w with offset as c | |
from | |
unnest([ | |
-- Will be named and explictly typed | |
-- STRUCT<x int64, y string>(1, 'a'), | |
-- STRUCT<x int64, y string>(2, 'b'), | |
-- STRUCT<x int64, y string>(3, 'c') |
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.
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
""" | |
Script to scrape Gigaclear status for each postcode (in this case in GL* areas) | |
Writes a Json file with lat-lon, postcode and response for display and | |
later reference | |
""" | |
import requests | |
import csv | |
import io | |
import time |
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
#!/usr/bin/env bash | |
DATASET="<YOUR DATASET HERE>" | |
TABLE="fun_with_time" | |
SCHEMA_FILE="/tmp/ts-schema.json" | |
DATA_FILE="/tmp/ts-data.ndjson" | |
SQL_FILE="/tmp/query.sql" | |
BUCKET="<YOUR BUCKET HERE>" | |
cat <<EOM >${SCHEMA_FILE} |
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
-- | |
-- Week Daily for non-Orthogonal Date dimensions e.g. day of week | |
-- | |
with Calendar as ( | |
select | |
this_year, | |
date_add(this_year, interval - 364 day) as last_year | |
from | |
unnest(GENERATE_DATE_ARRAY('2017-01-01', '2017-12-31')) as this_year | |
), |