Convert A Categorical Variable Into Dummy Variables

# import modules
import pandas as pd
# Create a dataframe
raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 
        'last_name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze'], 
        'sex': ['male', 'female', 'male', 'female', 'female']}
df = pd.DataFrame(raw_data, columns = ['first_name', 'last_name', 'sex'])
df

first_name last_name sex
0 Jason Miller male
1 Molly Jacobson female
2 Tina Ali male
3 Jake Milner female
4 Amy Cooze female
# Create a set of dummy variables from the sex variable
pd.get_dummies(df, columns=['sex'])

first_name last_name sex_female sex_male
0 Jason Miller 0 1
1 Molly Jacobson 1 0
2 Tina Ali 0 1
3 Jake Milner 1 0
4 Amy Cooze 1 0