- 博客(8)
- 收藏
- 关注
原创 pandas用法大全
一、生成数据表 1、首先导入pandas库,一般都会用到numpy库,所以我们先导入备用: import numpy as np import pandas as pd 2、导入CSV或者xlsx文件: df = pd.DataFrame(pd.read_csv(‘name.csv’,header=1)) df = pd.DataFrame
2017-09-05 21:01:40
226444
24
原创 python 链接MySQL数据库
Python的DB-API 使用流程: 1、引入API模块 2、获取与数据库的链接 3、执行SQL语句和存储过程 4、关闭数据库数据库查询操作# encoding:utf-8import MySQLdbdb = MySQLdb.connect("localhost","用户名","密码","数据库名")cursor = sb.cursor()# 使用execute方法执行SQL语句
2017-05-15 18:02:56
755
原创 Python 机器学习文章链接汇总
1、国内外网站 如果你想搜索比较新颖的机器学习资料或是文章,可以到以下网站中搜索,里面不仅包括了机器学习的内容,还有许多其它相关领域内容,如数据科学和云计算等。 InfoWord:http://www.infoworld.com/reviews/ Kdnuggets:http://www.kdnuggets.com Datasciencecentral:http://www.datascie
2017-04-01 16:32:37
799
原创 Python 读取TXT文件
一、打开文件f = open(filename,access_mode='r',buffering=-1)filename:文件名 access_mode:打开方式,r读,w写,a追加,r+ w+ a+ 都是以读写方式打开,rb二进制读,wb二进制写,rb+ wb+ ab+二进制读写 buffering:默认值 二、对文件进行操作 将文件中的内容读入到一个字符串变量/列表中 函数
2017-02-10 11:08:12
13612
原创 Python 列表转换为字典
# coding:utf-8import sysreload(sys)sys.setdefaultencoding('utf8')# 系统内置的实现def build_in(ls_key, ls_value): return dict([ls_key, ls_value])if __name__ == '__main__': ls_key = ['a','b'] l
2017-02-08 12:24:34
3902
原创 Python 决策树算法的实现
完整的程序如下:>from sklearn.feature_extraction import DictVectorizer>import csv>from sklearn import tree>from sklearn import preprocessing>from sklearn.externals.six import StringIO># 第一步:读取CSV文件>def t
2017-02-06 18:19:40
1546
转载 python内置函数大全
最近一直在看python的document,打算在基础方面重点看一下python的keyword、Build-in Function、Build-in Constants、Build-in Types、Build-in Exception这四个方面,其实在看的时候发现整个《The Python Standard Library》章节都是很不错的,其中描述了很多不错的主题。先把Build-in Fu
2017-02-05 11:34:13
378
原创 Python collection的使用
Python中的基本数据结构有list,dict,tuple,set。Python还有一个功能比较强大的包collections,可以处理并维护一个有序的dict,可以提高程序的运行效率。 1、collections中defaultdict的使用 defaultdict在字典dict的基础之上添加一个参数default_factory(default_factory可以指定为list,s
2017-01-19 17:58:10
14180
3
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人