Last answered:

09 Nov 2023

Posted on:

07 Nov 2023

0

Resolved: Dummy variable not converting to Zero's and Ones

Please why am I getting boolean values of false and true instead of zeros and ones


5 answers ( 1 marked as helpful)
Instructor
Posted on:

07 Nov 2023

0

Hi Nike!

Thanks for reaching out.

Can you please check the contents of the 'Reason for Absence' column prior to applying the .get_dummies() method? It seems that there's the key to this outcome.

Hope this helps but please feel free to get back to us should you need further assistance. Thank you!

Kind regards,
Martin

Posted on:

08 Nov 2023

0

Hi Martin, these were the steps I followed in line with the lectures before get_dummies, can you help identify the issue

And then after the error above, i get 

so what caused the error above, yet reason_columns gave an output?

Posted on:

08 Nov 2023

1

Hi Nike,

try  the code below in order to get 0 and 1 instead of True and False


reason_columns = pd.get_dummies(df['Reason for Absence'] ,dtype=int)

Posted on:

09 Nov 2023

0

Hi Jawad, 


Thanks, it worked. 

Instructor
Posted on:

09 Nov 2023

0

Hi Nike and jawad!

@jawad: Thank you very much for providing a solution.

Kind regards,
Martin

Submit an answer