Skip to content Skip to sidebar Skip to footer

Replace String In Dataframe If A Condition In A Different Row Is Met

I have a dataframe made up of a date and a value column, kind of like this: >>> df date value 0 2016-09-10 value1 1 2016-09-10 value1 2 2016-09-10 value2

Solution 1:

How about

>> df.loc[(df['date'] == '2016-09-10') & (df['value'] == 'value1'), 'value'] = 'value7'

You may want to read Indexing and Selecting Data section and this for more info


Solution 2:


Post a Comment for "Replace String In Dataframe If A Condition In A Different Row Is Met"