Skip to content

Instantly share code, notes, and snippets.

@charanhu
Created August 11, 2022 06:06
Show Gist options
  • Save charanhu/5867a54623da528bd4acdca6d4a35b36 to your computer and use it in GitHub Desktop.
Save charanhu/5867a54623da528bd4acdca6d4a35b36 to your computer and use it in GitHub Desktop.
# encoding sex column
insurance_dataset.replace({'sex':{'male':0, 'female':1}}, inplace=True)
# encoding smoker column
insurance_dataset.replace({'smoker':{'yes':0, 'no':1}}, inplace=True)
# encoding region column
insurance_dataset.replace({'region':{'southeast':0, 'southwest':1, 'northeast':2, 'northwest':3}}, inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment