Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính
John Miller
Principal Data Scientist
$$
Tình huống thường gặp
Nối dữ liệu theo hàng hoặc cột
pd.concat([df1, df2], axis=0)
$$

$$
Ghép một-một kiểu VLOOKUP
pd.merge(left_df, right_df,
how='inner',
on='key_column')

$$ Ghép (merge) theo cột khóa
df1.merge(df2, how='inner',
on='key_column')
$$
Ghép theo chỉ mục duy nhất
df1.join(df2, how='left')
$$

Tham số nâng cao
pd.merge_ordered(left_df, right_df, how='outer')pd.merge_asof(left_df, right_df, direction='backward')

Ghép nối dữ liệu bằng Pandas dành cho người dùng bảng tính