pandas à gauche rejoindre
df.merge(df2, left_on = "doc_id", right_on = "doc_num", how = "left")
Comfortable Cockroach
df.merge(df2, left_on = "doc_id", right_on = "doc_num", how = "left")
# df1 as main df and use the feild from df2 and map it into df1
df1.merge(df2,on='columnName',how='left')
df1 = pd.DataFrame(
{
"A": ["A0", "A1", "A2", "A3"],
"B": ["B0", "B1", "B2", "B3"],
}
)
df2 = pd.DataFrame(
{
"A": ["A4", "A5", "A6", "A7"],
"B": ["B4", "B5", "B6", "B7"],
}
)
df3 = pd.DataFrame(
{
"A": ["A8", "A9", "A10", "A11"],
"B": ["B8", "B9", "B10", "B11"],
}
)
frames = [df1, df2, df3]
result = pd.concat(frames, ignore_index=True)
"""
result = pd.DataFrame(
{
"A": ["A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11"],
"B": ["B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10", "B11"],
},
index=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
)
"""
#https://pandas.pydata.org/docs/user_guide/merging.html