Created
November 3, 2015 04:56
-
-
Save dyerrington/5fe39f81b9bc1b0f4db1 to your computer and use it in GitHub Desktop.
Basic left join example using pandas data frames.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_1 = pd.DataFrame([['Test 1', 'Dogs', 'Cats'], ['Test 2', 'Fogs', 'Squids']], columns=['Company', 'A1', 'A2']) | |
test_2 = pd.DataFrame([['Test 1', 4, 5, 6], ['Test 1', 6,3,1], ['Test 1', 3, 3, 1], ['Test 2', 2,3 ,4], ['Test 2', 7, 8, 9]], columns=['Company', 'V1', 'V2', 'V3']) | |
pd.merge(left=test_2, right=test_1, how='left', left_on='Company', right_on='Company') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment