Skip to content

Instantly share code, notes, and snippets.

@amorgun
amorgun / virtualenv.md
Last active March 31, 2016 07:22
How to create new virtualenv
virtualenv --no-site-packages --distribute -p `which python3` <env_name>

or simply

pyvenv <env_name>
@amorgun
amorgun / one-hot.py
Created March 4, 2016 13:35 — forked from ramhiser/one-hot.py
Apply one-hot encoding to a pandas DataFrame
import pandas as pd
import numpy as np
from sklearn.feature_extraction import DictVectorizer
def encode_onehot(df, cols):
"""
One-hot encoding is applied to columns specified in a pandas DataFrame.
Modified from: https://gist.github.com/kljensen/5452382