Skip to content
Advertisement

How to convert multiple pandas columns from string boolean to boolean?

I have this dataframe

JavaScript

I want to convert the string booleans to booleans.

I have tried

JavaScript

and

JavaScript

but neither of these worked.

Is it possible to do convert the type of multiple columns in a single line or do I have to convert the relevant columns one at a time?

Advertisement

Answer

You can use the dictionary version of replace.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement