Syed Amir Ali
Syed Amir Ali

Reputation: 1

Encoded result gives output as bolean instead of numeric

After performing OneHotEncoding, my data frame gives values for its columns as True and False, not as 1 and 0, what I am supposed to have. My code looks like this, where the data frame is ds and the categorical column name is "type":

pd.get_dummies(ds,columns = ["type"])

I'm trying to get a numeric result.

Upvotes: -2

Views: 39

Answers (1)

George
George

Reputation: 158

bool_val = True
print(bool_val)       # returns True
print(int(bool_val))  # returns 1

Upvotes: 0

Related Questions