Skip to content

Instantly share code, notes, and snippets.

@mahijar
mahijar / useful_pandas_snippets.py
Created January 9, 2018 13:52 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# 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!
@mahijar
mahijar / xor_keras.py
Created October 16, 2017 15:08 — forked from ricgu8086/xor_keras.py
Comparing XOR between tensorflow and keras
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
from keras.optimizers import SGD
X = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
y = np.array([[0],[1],[1],[0]], "float32")
model = Sequential()
model.add(Dense(2, input_dim=2, activation='sigmoid'))
@mahijar
mahijar / install-tensorflow.sh
Created August 11, 2016 13:25 — forked from erikbern/install-tensorflow.sh
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update
@mahijar
mahijar / get_pdfs.py
Last active August 29, 2015 14:27 — forked from jstacoder/get_pdfs.py
download files from it-ebooks.info, from the command line
# requires twill==0.9
import sys
from twill import get_browser
from pprint import pprint
class PdfFinder:
browser = None
_b = None
_q = None
links = {}
import urllib
import re
import time
data = urllib.urlopen('http://bitly.measuredvoice.com/bitly_archive/?C=M;O=D').read()
#print data
#datafiles name pattern - usagov_bitly_data2011-07-29-1311919454