I'm having trouble copying some data between 2 dataframes. I have the main_df:
main_df = pd.DataFrame({"id": [123, 456, 789, 357, 159], "date": [None, "2022-10-10", "2022-09-15", None, "2022-09-15"], "stuff": [3, 6, 2, 9, 3]})
id             date  stuff 
123             NaN      3
456      2022-10-10      6
789      2022-09-15      2
357             NaN      9
159      2022-09-15      3
and second_df:
second_df = pd.DataFrame({"id": [321, 456, 789, 789, 351], "stuff": [3, 6, 2, 4]})
id   stuff 
321      3
456      6
789      2
351      4
I want to search if an id in second_df is in main_df and copy the date that appear in main_df to second_df. This would be the result:
id   stuff         date
321      3          NaN
456      6   2022-10-10
789      2   2022-09-15
351      4          NaN  
I know that with second_df["id"].isin(main_id["id"]) I can get a dataframe/column/Series with boolean results indicating if the id exists, but I don't know how to copy the date value.
Hope someone can help me, thanks.
 
    