下面是 pandas 的练习操作
通过这些操作,我们能够:
1. 读入一个 csv 文件到 Pandas DataFrame
2. 显示该 Pandas DataFrame 的内容以及数据 shape
3. 对行和列进行筛选
4. 计算列的avg 和 sum
5. 合并两个 Pandas DataFrame
>> jupyter notebook你可以在以下网页找到 关于 pandas 的基本操作的列表:
import pandas as pd buyclicksDF = pd.read_csv('buy-clicks.csv') # print(buyclicksDF) # to show the top 5 items buyclicksDF.head(5) # to show the data shape buyclicksDF.shape buyclicksDF[['price', 'userId']].head(5) buyclicksDF[buyclicksDF['price'] < 3.].head(5) buyclicksDF['price'].sum() buyclicksDF['price'].mean() adclickDF = pd.read_csv('ad-clicks.csv') adclickDF.head(5) mergeDF = adclickDF.merge(buyclicksDF, on = 'userId') mergeDF.head(5)你可以亲自操作一下,看看结果是什么