Skip to content
Advertisement

Pandas – converting yes : no to True : False failing

My best efforts to convert a column with ‘yes’ ‘no’ values to True, False or 1 , 0 are failing. The column is ‘subscribed’.

JavaScript

Tried the following. None of them worked:

JavaScript

Advertisement

Answer

As EdChum points out you need to assign back to the df.

JavaScript

Input:

JavaScript

Output:

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