Title: Merge/Concat dataframe using left join concept
Tags: python;pandas;dataframe;merge;concatenation
Question: I was working with dataframes and I came across a problem I was not able to solve.
Suppose I have a dataframe A and dataframe B
0 NAME1 20
1 NAME2 30
2 NAME3 40
0 NAME1 10
1 NAME2 100
2 NAME4 50
I want the output as-
Output -
0 NAME1 20
1 NAME2 30
2 NAME3 40
3 NAME4 50/0
For the last one anything would work either 50 or 0. This is a combination of both concat and merge. I have to concat but with left join logic. How can I do this using pandas functions?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:02/16/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><pandas><dataframe><merge><concatenation>', 'Title': 'Merge/Concat dataframe using left join concept', 'ViewCount': 18, 'id': 71142527, 'user_AboutMe': None, 'user_AccountId': 12875491.0, 'user_DisplayName': 'Sarthak Agrawal', 'user_Reputation': 29.0, 'user_Views': 5.0, 'user_id': 9312339.0}}