0
推荐
1507
阅读

Pandas学习1

pandas有两种自己独有的基本数据结构Series和DataFrameSeries数据结构 data 100 300 500 index 0 1 2 或者 index data 0 100 1 300 2 500 创建series对象 In [1]: import numpy as np In [2]: from pandas import Series,DataFrame In [3]: import pandas as pd 传递list创建...

发表了文章 • 2017-09-04 14:18 • 0 条评论

0
推荐
1236
阅读

Numpy学习1

NumPy学习(1)参考资料:http://www.cnblogs.com/zhanghaohong/p/4854858.htmlhttp://linusp.github.io/2016/02/25/creation-and-io-of-ndarray.html数组的创建数组属性数组元素获取-普通索引、切片、布尔索引、花式索引统计函数与线性代数运算随机数的生成NumPy数组:NumPy数组是一个多维数组对象,称为ndarray。数组的...

发表了文章 • 2017-09-04 14:12 • 0 条评论

0
推荐
1088
阅读

centos下安装python2.7.9和pip以及数据科学常用的包

以前一直用ubantu下的python,ubantu比较卡。自己倾向于使用centos,但默认的python版本太低,所以重新装了一个python和ipythoncentos6.5安装python2.7.9第一步:安装devtoolset[root@spark1 ~]# yum groupinstall "Development tools"第二步:安装编译python所需要的包[root@spark1 ~]# ...

发表了文章 • 2017-08-18 14:25 • 0 条评论

0
推荐
1085
阅读

python基础-面向对象

类和对象面向过程的编程:C面向对象的编程:C++,JAVA,Python类:对事物的抽象,如汽车模型对象:类的一个实例。如大客车python类定义:使用class关键字定义一个类,并且类名首字母要大写。在类中可以定义一些变量(属性)和函数(方法)             ...

发表了文章 • 2017-08-18 10:43 • 0 条评论

0
推荐
908
阅读

python爬取糗事百科段子

初步爬取糗事百科第一页段子(发布人,发布内容,好笑数和评论数) #-*-coding:utf-8-*- import urllib import urllib2 import re page = 1 url ='http://www.qiushibaike.com/hot/page/'+str(page) #第一页URL headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox...

发表了文章 • 2017-08-18 10:33 • 0 条评论

0
推荐
3393
阅读

python爬虫-韩寒新浪博客博文

博客地址:http://blog.sina.com.cn/s/articlelist_1191258123_0_1.html爬第一页博文#-*-coding:utf-8-*- import re #导入正则表达式模块 import urllib #导入urllib库 url='http://blog.sina.com.cn/s/articlelist_1191258123_0_1.html' #第一页博文地址 response = urllib.urlopen(url) #通过urllib库...

发表了文章 • 2017-08-16 16:55 • 0 条评论

0
推荐
1111
阅读

python-函数

函数基础定义函数使用def语句,依次写出函数名、括号、括号中的参数和冒号:然后在缩进中编写函数体,返回值用return语句返回计算字符串中某字符个数def countsubstring(s,ch): #s和ch为形参 c=0 i=0 while i

发表了文章 • 2017-08-16 16:45 • 0 条评论

0
推荐
1049
阅读

Python-列表

列表基础列表定义:一有序数据集合用逗号间隔用方括号括起来列表的索引访问(索引list_name[index]和切片list_name[start:end:step]) wu=[1,2,3,4] print(wu[1]) wu[1]=[5,6,7] print(wu) print(wu[1][1])[root@localhost ~]# python 1.py 2 [1, [5, 6, 7], 3, 4] 6列表遍历 wu=[1,2,3,4] #### iteror for ...

发表了文章 • 2017-08-16 16:30 • 0 条评论

0
推荐
998
阅读

Python-字符串

字符串基础1 字符串定义:用引号引起来的字符集合称之为字符串(单引号,双引号,三双引号,三单引号)    三引号(三单或三双)支持多行或也可表示注释,而单双引只能一行(但是可以加\n)2 转义字符串:常见有 \n 回车字符,         \t 下一制表位 &nbs...

发表了文章 • 2017-08-16 15:55 • 0 条评论

0
推荐
1024
阅读

python爬虫-正则表达式

特此声明:以下内容来源于博主:http://www.cnblogs.com/huxi/                                    http://blog.csdn.net/pleasec...

发表了文章 • 2017-08-16 15:14 • 0 条评论

0
推荐
1127
阅读

python爬虫-异常处理

URLerror产生原因:网络未连接(即不能上网)服务器不存在 #-*-coding:utf-8-*- import urllib2 request=urllib2.Request('http://www.wujiadong.com')#这是一个不能打开的网址 response=urllib2.urlopen(request) html=response.read() print(html)报错情况:下面我们对可能出现异常进行处理,一般通过try-exc...

发表了文章 • 2017-08-16 15:06 • 0 条评论

0
推荐
1137
阅读

python爬虫-url

特此声明:以下内容来源于博主:http://blog.csdn.net/pleasecallmewhy                                     http://cuiqing...

发表了文章 • 2017-08-16 14:31 • 0 条评论

0
推荐
773
阅读

python-模块

例如:打印出16的平方根 import math x=16.0 y=math.sqrt(x) print(x,y,math.pi) x=math.pi/6 y=math.sin(x) print(y)[root@localhost ~]# python 1.py (16.0, 4.0, 3.141592653589793) 0.5查看模块里的函数import math help(math)例2: import math x=2 y=3 a=math.pow(x,y) print(int(a)) #in...

发表了文章 • 2017-08-16 13:46 • 0 条评论

0
推荐
1132
阅读

python-字符串应用

1 字符串中某元素计数2 字符串替换3 字符串反向输出【注意python最右端是开区间】例1:计算碱基A,T,G,C的数量 s='ATGCATGCCGTAATGCGCTA' s='ATGCATGCCGTAATGCGCTA' print(s.count('A')) print(s.count('G')) print(s.count('C')) print(s.count('T'))[root@localhost ~]# python 1.py 5 5 5 5例2:将DNA连中...

发表了文章 • 2017-08-16 13:39 • 0 条评论

0
推荐
955
阅读

python-条件和循环

if循环:有条件的执行,做出选择例1: a=42 if a=100: print('the number is larger or equal to 100') else: print('the number is less than 100')    [root@localhost ~]# python 1.py the number is larger or equal to 100 例4(if嵌套) a='F' b=30 if a=='M': if b>=...

发表了文章 • 2017-08-16 13:31 • 0 条评论