Skip to content
Advertisement

Replacing values in a pandas dataframe taking row number into account

I have this dataframe taken from an excel file and I want to replace the value column with a string that contains the row number (+1 and with an F so it reference another cell in excel) if the state is “no”. I had no problem replacing some values in the comment column with

JavaScript

but I dont know how take the row number into account.

Input:

JavaScript

Output:

JavaScript

Advertisement

Answer

Use boolean indexing:

JavaScript

Output:

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