Skip to content
Advertisement

I’m trying to replace/convert all the A’s and B’s in a particular column to 1 and O in a csv file

This is the error i’m getting

JavaScript

This is what i have tried

repl = {‘Y’:’1′, ‘N’:’0′} prices_dataframe[‘col_state’] = prices_dataframe[‘col_state’].replace(repl, regex=True)

Advertisement

Answer

The replace() method is unique to strings, and at some point the value you are trying to replace is being a boolean (True or False). If you still want to replace it, you can transform the value into a string:

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