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:
If you want to keep everything else same and change what you need, try this,
df.loc[df['date'] == '2016-09-10' , 'value'] = 'value7'
Post a Comment for "Replace String In Dataframe If A Condition In A Different Row Is Met"