Last active
May 21, 2017 14:23
-
-
Save lfarroco/b3516b92a797e93656bf2a7c69ed0f36 to your computer and use it in GitHub Desktop.
One-hot Encoding using Pandas DataFrames
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 pandas as pd | |
data = pd.DataFrame([ | |
["Team A",1,0], | |
["Team B",0,1]], | |
columns=["Team","Attribute A","Attribute B"]) | |
pd.get_dummies(data) | |
#Output will be: | |
# Attribute A Attribute B Team_Team A Team_Team B | |
#0 1 0 1 0 | |
#1 0 1 0 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment