Quantcast
Channel: Changing a value of first data frame for rows that match with 2nd data frame in python - Stack Overflow
Browsing index pages (3 articles)

Changing a value of first data frame for rows that match with 2nd data frame...

For example, if first data frame df1 is:'a''b''value'0 1 2 11 2 3 1and second data frame df2 is'a''b'0 1 2I would like to get something like'a''b''value'0 1 2 01 2 3 1For all the rows in df1(excluding...

View Article


Answer by Psidom for Changing a value of first data frame for rows that match...

You can specify the indicator parameter to be true when merging, this will generate an extra column specify if the rows come from both sides, and then you can modify the value column based on the...

View Article


Answer by nitinvijay23 for Changing a value of first data frame for rows that...

You can find the common rows using the inner join.df1.merge(df2, how= "inner", left_index= True, right_index= True)If you want the output you posted then you can use left joindf2.merge(df1, how="left",...

View Article
Browsing index pages (3 articles)


Latest Images