Exercise

Converting new categories to numeric

You reduced the 12 category variable into three distinct categories by creating a new school_type column, which contains a string encoding of the school type with the ranges of grades. Now, use one-hot encoding to represent each category independently.

Instructions

100 XP
  • Create an elem_sch column that encodes each row that corresponds to elementary_school as 1 and set everything else to 0.
  • Create a mid_sch column that encodes each row that corresponds to middle_school as 1 and set everything else to 0.
  • Create a high_sch column that encodes each row that corresponds to high_school as 1 and set everything else to 0.