Python数据分析博文汇总
- Pandas重复值处理函数drop_duplicates()
- Pandas数据库缺失值处理函数dropna
- Pandas中slice函数字段抽取
- python数据分析-DataFrame数据框基本知识
- Pandas数据库数据抽取
- Numpy.random.randint()函数用法及源码
- Pandas.concat()函数用法及源码
- Pandas数据框列合并详解
- Pandas.merge()函数用法及源码
- Pandas之数据框框运算
- Pandas之数据标准化
- Pandas.cut函数用法及源码
- python数据框空格值处理
- Pandas.split()函数用法及源码
字段匹配:将不同结构的数据框,按照一定的条件进行合并
函数用法:merge(df1, df2, column of df1, column of df2)
import pandas;
from pandas import read_csv;
items = read_csv(
"E:\\pythonlearning\\datacode\\firstpart\\4\\4.12\\data1.csv",
sep='|',
names=['id', 'comments', 'title']
);
prices = read_csv(
"E://pythonlearning//datacode//firstpart//4//4.12//data2.csv",
sep='|',
names=['id', 'oldPrice', 'nowPrice']
);
itemPrices = pandas.merge(
items,
prices,
left_on='id',
right_on='id'
);#以'id'列用基准,合并数据框
运行前12行得到:
再运行剩余行:
源代码:https://download.csdn.net/download/w_weiying/10427108