Skip to content

Instantly share code, notes, and snippets.

@aok1425
Last active February 20, 2017 04:21
Show Gist options
  • Save aok1425/4d359460544de330d818d869ee6d1417 to your computer and use it in GitHub Desktop.
Save aok1425/4d359460544de330d818d869ee6d1417 to your computer and use it in GitHub Desktop.
# push subfolder in git repo called "app" to heroku
git push heroku `git subtree split --prefix app master`:master --force
###
pd.set_option('max_colwidth', 400)
from IPython.display import display
with pd.option_context("display.max_columns", 50):
display(df.head(2))
from IPython.core.debugger import Tracer; Tracer()()
###
from __future__ import division
import pandas as pd
import warnings
import seaborn as sns
import matplotlib.pyplot as plt
from pylab import rcParams
%matplotlib inline
warnings.filterwarnings("ignore", category=DeprecationWarning)
sns.set_style("whitegrid")
sns.set_context("poster")
rcParams['figure.figsize'] = 20, 5
from scipy.sparse import csc_matrix
from zipcode_mapping import zipcode_mapping
##
# grep recursively through files of a certain type, such as .py files
grep -R --include="*.py" "pattern" /path/to/dir
find . -name *simple*
##
def dummify(df, column):
# from Darren's linear regression slides
print '{} is your baseline'.format(sorted(df[column].unique())[-1])
dummy = pd.get_dummies(df[column]).rename(columns=lambda x: column+'_'+str(x)).iloc[:,0:len(df[column].unique())-1]
df = df.drop(column,axis=1) #Why not inplace? because if we do inplace, it will affect the df directly
return pd.concat([df,dummy],axis=1)
##
with pd.option_context("display.max_rows", 200):
display(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment