pandas 遍历有以下三种访法. iterrows():在单独的变量中返回索引和行项目,但显着较慢 itertuples():快于.iterrows(),但将索引与行项目一起返回,ir [0]是索引 zip:最快,但不能访问该行的索引 df= pd.DataFrame({'a': range(0, 10000), 'b': range(10000, 20000)}) 0.for i in df:并不是遍历行的方式 for i in df: print(i) 正式因为for in df不是直接遍…
待补充:https://www.cnblogs.com/zknublx/p/6042295.html 一.使用集合直接去重 ids = [1,4,3,3,4,2,3,4,5,6,1]ids = list(set(ids)) 处理起来比较简单,使用了集合方法set进行处理,不过结果不会保留之前的顺序. 二.列表法 ids = [1,2,3,3,4,2,3,4,5,6,1]news_ids = []for id in ids: if id not in news_ids: new…
如果Pandas只是能把一些数据变成 dataframe 这样优美的格式,那么Pandas绝不会成为叱咤风云的数据分析中心组件.因为在数据分析过程中,描述数据是通过一些列的统计指标实现的,分析结果也需要由具体的分组行为,对各组横向纵向对比. GroupBy 就是这样的一个有力武器.事实上,SQL语言在Pandas出现的几十年前就成为了高级数据分析人员的标准工具,很大一部分原因正是因为它有标准的SELECT xx FROM xx WHERE condition GROUP BY xx HAVING…
http://blog.csdn.net/pipisorry/article/details/53320669 pyspark.sql.SQLContext Main entry point for DataFrame and SQL functionality. [pyspark.sql.SQLContext] 皮皮blog pyspark.sql.DataFrame A distributed collection of data grouped into named columns. sp…
#读csv,excel,json数据 with open('E:\\test\\xdd.csv','r') as f: for line in f.readlines(): print(line) import pandas df = pandas.read_csv('E:\\test\\xdd.csv') print(df) import pandas df = pandas.read_excel('E:\\test\\aa.xls') print(df) import json with o…
房天下 import requests res = requests.get('http://esf.sz.fang.com/') #res.text from bs4 import BeautifulSoup soup = BeautifulSoup(res.text,'html.parser') domain = 'http://esf.sz.fang.com' for house in soup.select('.houseList dl'): if len(house.select('.…