Created
May 4, 2022 11:45
-
-
Save masiarek/d7f87a44d7920851b3f3495328b3a51b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import pandas as pd | |
from io import StringIO | |
import io | |
A = """ | |
k1,k2,a3 | |
1,44,x | |
2,55,y | |
3,66,z""" | |
B = """ | |
k1,k2,b3 | |
1,44,ham | |
2,55,egg | |
NULL,NULL,NULL""" | |
C = """ | |
c1,k2 | |
NULL,NULL | |
bar,55 | |
baz,66""" | |
D = """ | |
a1 a2 a3 b3 c1 | |
1 44 x ham NULL | |
2 55 y egg bar | |
3 66 z NULL baz""" | |
dfA = pd.read_csv(io.StringIO(A)) | |
dfB = pd.read_csv(io.StringIO(B)) | |
dfC = pd.read_csv(io.StringIO(C)) | |
l_join = pd.merge(dfA, dfB, how="left", sort=False) | |
print(l_join) | |
together = pd.merge(l_join, dfC, how="left", sort=False) | |
print(together) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment