Skip to content

Instantly share code, notes, and snippets.

@vinimonteiro
Created October 26, 2021 16:18
Show Gist options
  • Save vinimonteiro/88c17beac6509e3957ae23599335bb45 to your computer and use it in GitHub Desktop.
Save vinimonteiro/88c17beac6509e3957ae23599335bb45 to your computer and use it in GitHub Desktop.
One hot encoding with get_dummies
import pandas as pd
df = pd.read_table('https://data.princeton.edu/wws509/datasets/salary.dat',delim_whitespace=True)
dummy = pd.get_dummies(df['sx'])
print(dummy.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment