数据准备
source/product.csv
uid,product,price 1,百度,200 2,360,300 3,腾讯,400
source/person.csv
uid,name,product,age 1,李彦宏,百度,43 2,马化腾,腾讯,36 3,周鸿祎,360,34 • 1 • 2 • 3 • 4
备注,逗号分隔的时候不要留空格
代码示例
import pandas as pd person = pd.read_csv("source/person.csv") product = pd.read_csv("source/product.csv") info = pd.merge(person, product, on="product") print(info.head(10)) """ uid_x name product age uid_y price 0 1 李彦宏 百度 43 1 200 1 2 马化腾 腾讯 36 3 400 2 3 周鸿祎 360 34 2 300 """
参考