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
# @parsethis | |
# Basic LRU Cache implementation using a dictionary and a queue | |
# Goes without saying that you'd not use this, functools.lru_cache is what you want | |
# TODO, is not threadsafe, not nearly use locking (see functools.lru_cache ) | |
# hashing keys could be flattened, properly hashed | |
# maybe you want a doubly linked list and not a python queue | |
# | |
# |
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
# List unique values in a DataFrame column | |
# h/t @makmanalp for the updated syntax! | |
df['Column Name'].unique() | |
# Convert Series datatype to numeric (will error if column has non-numeric values) | |
# h/t @makmanalp | |
pd.to_numeric(df['Column Name']) | |
# Convert Series datatype to numeric, changing non-numeric values to NaN | |
# h/t @makmanalp for the updated syntax! |
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 numpy as np | |
from keras.preprocessing.sequence import pad_sequences | |
from keras.utils import to_categorical | |
from keras.models import Sequential | |
from keras.layers import Embedding, Dense, LSTM | |
def main(): | |
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 | |
title, timestamp, score, url | |
FROM | |
[bigquery-public-data.hacker_news.full] | |
WHERE | |
(REGEXP_MATCH(url,r'nytimes.com|cnn.com|hufftingtonpost.com|usatoday.com|reuters.com|politico.com|yahoo.com | |
|npr.org|latimes.com|nbcnews.com|cbsnews.com|nypost.com|abcnews.com|breitbart.com|theonion.com | |
|newsmax.com|washingtontimes.com|newsweek.com|observer.com|chicago.suntimes.com|theguardian.com | |
|buzzfeed.com|wjs.com|abcnews.go.com|news.bbc.co.uk|usatoday.com|bloomberg.com|news.google.com')) | |
AND deleted IS null AND type='story' |
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
from keras.engine.topology import Layer | |
from keras import initializations | |
from keras import backend as K | |
class Attention(Layer): | |
'''Attention operation for temporal data. | |
# Input shape | |
3D tensor with shape: `(samples, steps, features)`. | |
# Output shape | |
2D tensor with shape: `(samples, features)`. |
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
#!bin/env/python | |
# Simple script I used to get make a map from ACS | |
# survey data variable names to the descriptive table names. | |
# It made my life a bit easier when searching for table names | |
# programmatically | |
# here is the ACS varibles site: | |
# http://api.census.gov/data/2014/acs5/variables.html |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.