Categorical Variable : Gender | dtype: Object | Values: Male, male, m, M, Female, female, f, F |
I want to replace all values to 'Male' & 'Female' accoridingly. Replace is not working, showing that 'Male' and 'Female' does not exist. I can replace them by 1 & 0 but I don't want to make it an ordinal variable
This is my code:-
bck = pd.read_csv('BCK.csv')
bck['Gender'].value_counts()
bck.Gender.dtype
bck['Gender'] = bck['Gender'].astype('str')
bck.Gender.dtype
bck.Gender.replace(to_replace=dict(m = Male, f = Female, male = Male, female = Female, M = Male, F = Female), inplace=True)
This is not working and displaying, " Male does not exist".