Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is pd.get_dummies returning Boolean values instead of the binaries of 0 1

I don't know why my One-Hot encoding code; "pd.get_dummies" is returning Boolean values instead of the binaries of 0 1 df = pd.get_dummies(df)

after writing the following line of code; df = pd.get_dummies(df) and also tried; df = pd.get_dummies(df, columns=['column_a', 'column_b', 'column_c']) the returning values of both were booleans True and False instead of 0 and 1

like image 771
shasilon Avatar asked Oct 11 '25 12:10

shasilon


1 Answers

By default pd.get_dummies return Boolean, try :

df = pd.get_dummies(df, dtype=int)
like image 129
حمزة نبيل Avatar answered Oct 14 '25 14:10

حمزة نبيل