Merging Dataframes and getting extra rows. (Python/Pandas)
As @Paul H said, you need an aggregation on the second dataframe
df2.groupby("ID")["Raise"].any()
Then you can merge with the first one using ID.
Suppose I have two data frames. One with employee IDs. And one with employee IDs and a Boolean value that indicates if they were given a raise when they asked (they can ask multiple times).




ID




5


8


9


22







ID
Raise




5
True


5
False


5
True


8
True


9
True


22
False




How can I create a dataframe that merges employee IDs and whether they were given a raise (regardless of how many times they asked)? Like the following.




ID
Raise




5
True


8
True


9
True


22
False




Whenever I try to merge normally, extra rows are created due to multiple of the same ID.