Skip to content

Instantly share code, notes, and snippets.

@ksdkamesh99
Created July 30, 2020 07:15
Show Gist options
  • Save ksdkamesh99/c1b950ef6f041ba8bc6d234bb0e98949 to your computer and use it in GitHub Desktop.
Save ksdkamesh99/c1b950ef6f041ba8bc6d234bb0e98949 to your computer and use it in GitHub Desktop.
# Importing Required Libraries
import pandas as pd
import numpy as np
# Reading the dataset with column as Sex
data=pd.read_csv('train.csv',usecols=['Sex'])
# Change column name to Gender
data.columns=['gender']
# We need to get dummies for the categorical data we have using get_dummies()
gender=pd.get_dummies(data)
#concatenating the dummies data frame with original dataframe by taking columns in the axis.
data=pd.concat([data,gender],axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment