![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
panpan_v1
这个作者很懒,什么都没留下…
展开
-
dataframe 分组后多列计算
g = history.groupby(by=['LinkTradeCode', 'InstrumentType', 'PutOrCall', 'KnockPrice', 'InstrumentGroup']).agg({'Volume': sum, 'CashCNY': sum}) # 取消分组后的索引 h = g.reset_index()原创 2019-03-26 16:54:14 · 4507 阅读 · 1 评论 -
python Beautiful Soup库入门
1. 简介 Beautiful Soup库是解析、遍历、维护“标签树”的功能库。 2. 安装和引用 直接安装bs4即可 from bs4 import BeautifulSoup 3. 基本元素 4. 遍历方法 5. HTML页面的友好输出 ...转载 2019-06-24 16:48:45 · 83 阅读 · 0 评论 -
爬虫实例1 - 大学排名
# CrawUnivRankingA.py import requests from bs4 import BeautifulSoup import bs4 def getHTMLText(url): try: r = requests.get(url) r.raise_for_status() r.encoding = r.appar...转载 2019-06-26 16:58:12 · 98 阅读 · 0 评论 -
基于bs4库的HTML内容的查找方法
.find_all()返回一个列表类型,存储查找的结果转载 2019-06-25 15:53:09 · 119 阅读 · 0 评论 -
python requests库的应用
1. 爬取购物网站商品页面 url = "http://item.jd.com/2967929.html" try: r = requests.get(url) r.raise_for_status() r.encoding = r.apparent_encoding print(r.text) except: print("爬取失败") 2. 修改u...转载 2019-06-21 15:45:09 · 73 阅读 · 0 评论 -
python requests库入门
1. 通用框架 2. requests库的方法 爬虫一般get()和head()用的较多 3.requests.request(method, url, **kwargs)详解 4. 除了request以外的其它方法 ...转载 2019-06-20 15:48:08 · 100 阅读 · 0 评论 -
self,cls和@staticmethod的区别
self => instancemethod 1、instance method 就是实例对象与函数的结合。 2、使用类调用,第一个参数明确的传递过去一个实例。 3、使用实例调用,调用的实例被作为第一个参数被隐含的传递过去。 简单来说,就是带了self这个参数的函数,如果想要调用的话必须先创建一个类的实例,因为调用的时候会隐含地传入调用的实例作为第一个参数。 ...转载 2019-05-09 11:16:03 · 115 阅读 · 0 评论 -
with语句
with open('../docs/trade_date.txt', 'r') as file: dates = file.read() 这样就无所谓会不会忘记close()了,省了try原创 2019-04-24 15:07:31 · 79 阅读 · 0 评论 -
robots协议
网络爬虫排除标准(对聚焦爬虫不适用) 告诉搜索引擎(爬虫)哪些页面可以抓取,哪些页面不能抓取。 例如:https://www.taobao.com/robots.txt原创 2019-04-23 16:18:05 · 82 阅读 · 0 评论 -
python 列表推导式
[表达式for变量in列表] 或者 [表达式for变量in列表if条件] 例如, 含字典的列表,想取所有的value重组个列表: instruments = [x["Underlying"] for x in instruments_list] instruments = [x["Underlying"] for x in instruments_list ...原创 2019-04-10 16:38:49 · 107 阅读 · 0 评论 -
dataframe 求差集
trade = pd.DataFrame(self.trade) option = pd.DataFrame(self.option) trade = trade.append(option ) trade = trade.append(option ) # 求差集要append两次 diff = trade.drop_duplicates(subset=['LinkTradeCode', 'P...原创 2019-03-26 16:58:31 · 3038 阅读 · 2 评论 -
正则表达式与re库
转载 2019-06-28 17:24:07 · 93 阅读 · 0 评论