This file contains 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 sklearn.feature_extraction import DictVectorizer | |
import pandas as pd | |
df = pd.DataFrame({"user_name": ["a", "b", "c"]}) | |
fe_lm = DictVectorizer() | |
design_lm = fe_lm.fit_transform(df.to_dict(orient="records")) | |
# Note that this solution is *MUCH* faster (60 times) than transposing and converting into a dictionary: | |
# http://fastml.com/converting-categorical-data-into-numbers-with-pandas-and-scikit-learn/ is much slower |
This file contains 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 gzip | |
from functools import wraps | |
import boto3 | |
from sqlalchemy import MetaData | |
from pandas import DataFrame | |
from pandas.io.sql import SQLTable, pandasSQL_builder | |
import psycopg2 | |
import codecs | |
import cStringIO | |
from io import BytesIO |