Issue
I have multiple df and i want to compare one with the other if the values are same. And if values are not same i want to append the value to the first data frame. For example: data frame 1
A | B | C |
---|---|---|
Mm | hh | jj |
Kk | ll | gg |
Data frame 2 | A | B | C | |---|---|---| | Oo|ii |ff | | Mm|hh |jj |
Final df | A | B | C | |---|---|---| | Mm|hh |jj | | Kk|ll |gg | | Oo|ii |ff |
Also i want to compare all the columns
Solution
Use pd.concat
to combine the two data frames and then apply drop_duplicates
method to remove all the duplicate rows
final = pd.concat([df1, df2], axis=0).drop_duplicates().reset_index()
Answered By - vignesh kanakavalli
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.