03 2020 档案

摘要:pandas提供了⼀些⽤于将表格型数据读取为DataFrame对象的函数。表6-1对它们进⾏了总结,其中read_csv和read_table可能会是你今后⽤得最多的。 1.read_csv 1. In [9]: df = pd.read_csv('examples/ex1.csv') In [10 阅读全文
posted @ 2020-03-22 21:42 爬爬QQ 阅读(363) 评论(0) 推荐(0)
摘要:DataFrame索引选项 2.在算数方法中填充值 ser=DataFrame(np.arange(9).reshape(3,3),columns=list('abc')) ser1=DataFrame(np.arange(12).reshape(3,4),columns=list('abcd')) 阅读全文
posted @ 2020-03-21 21:14 爬爬QQ 阅读(256) 评论(0) 推荐(0)
摘要:1. 纯python In [247]: import random .....: position = 0 .....: walk = [position] .....: steps = 1000 .....: for i in range(steps): .....: step = 1 if r 阅读全文
posted @ 2020-03-20 10:20 爬爬QQ 阅读(281) 评论(0) 推荐(0)
摘要:一、plt.imshow() plt.imshow() plt.imshow(z, cmap = plt.cm.gray_r)#其中z为绘制对象 .imshow() Plotting numpy arrays as images plt.cm.gray_r Colormap 加上_r相当于颜色 re 阅读全文
posted @ 2020-03-19 16:23 爬爬QQ 阅读(155) 评论(0) 推荐(0)
摘要:1.numpy.random.randn()用法 https://blog.csdn.net/u012149181/article/details/78913167 2.transpose和swapaxes的用法 https://blog.csdn.net/qq1483661204/article/ 阅读全文
posted @ 2020-03-19 15:12 爬爬QQ 阅读(227) 评论(0) 推荐(0)
摘要:transpose和swapaxes函数 transpose() 这个函数如果括号内不带参数,就相当于转置,和.T效果一样,而今天主要来讲解其带参数。 我们看如下一个numpy的数组: `arr=np.arange(16).reshape((2,2,4)) arr= array([[[ 0, 1, 阅读全文
posted @ 2020-03-19 15:10 爬爬QQ 阅读(202) 评论(0) 推荐(0)
摘要:方法一: path='d:/NEWS.txt' #以写模式打开路径文件,若不存在则创建,存在则覆盖,写入nihao f=open(path,'w') f_name.write('NIHAO') #以读模式打开路径文件 f_name=open(path,'r') #读取文件 f_name.read() 阅读全文
posted @ 2020-03-18 21:08 爬爬QQ 阅读(333) 评论(0) 推荐(0)
摘要:In [197]: float('1.2345') Out[197]: 1.2345 In [198]: float('something') ValueError Traceback (most recent <ipython-input-198-439904410854> in <module> 阅读全文
posted @ 2020-03-18 20:45 爬爬QQ 阅读(2072) 评论(0) 推荐(0)
摘要:enumerate函数 ,Python内建了⼀个enumerate函数,可以返 回(i, value)元组序列: for i, value in enumerate(collection): # do something with value 当你索引数据时,使⽤enumerate的⼀个好⽅法是计算 阅读全文
posted @ 2020-03-18 16:12 爬爬QQ 阅读(560) 评论(0) 推荐(0)
摘要:1.另外一种格式化方法: template = '{0:.2f} {1:s} are worth US${2:d}' {0:.2f}表示格式化第⼀个参数为带有两位⼩数的浮点数。 {1:s}表示格式化第⼆个参数为字符串。 {2:d}表示格式化第三个参数为⼀个整数。 template.format(4. 阅读全文
posted @ 2020-03-18 14:37 爬爬QQ 阅读(147) 评论(0) 推荐(0)
摘要:在scrapy项目文件夹中新建一个文件,代码如下 from scrapy.cmdline import execute execute("scrapy crawl top250".split()) 原理见 https://blog.csdn.net/qq_39377418/article/detai 阅读全文
posted @ 2020-03-14 21:25 爬爬QQ 阅读(197) 评论(0) 推荐(0)
摘要:#PythonDraw.py import turtle #绘图库 turtle.setup(1000, 1000, 0, 0) ''' turtle.setup(width, height, startx, starty),设置画布窗体的大小及位置,4个参数中后两个可选setup()不是必须的 ' 阅读全文
posted @ 2020-03-14 21:20 爬爬QQ
摘要:1.设置file-settings-Projectinterpreter 设置virtualenv environment-existingenvironment 设置system interpreter 2.设置run-edit configurations-,重点是该界面的EXCECUTE部分 阅读全文
posted @ 2020-03-14 21:03 爬爬QQ 阅读(156) 评论(0) 推荐(0)
摘要:1 import scrapy 2 from text_info.items import TextInfoItem 3 4 class A50zwSpider(scrapy.Spider): 5 name = '50zw' 6 allowed_domains = ['m.50zw.la'] 7 s 阅读全文
posted @ 2020-03-13 23:59 爬爬QQ 阅读(488) 评论(0) 推荐(0)
摘要:1.创建scrapy框架和爬虫程序 2.定义settings.py 3.编写spider爬虫程序 1 #!/usr/bin/python3 2 #-*-coding:UTF-8-*- 3 import scrapy 4 import sys 5 import time 6 sys.path.appe 阅读全文
posted @ 2020-03-13 21:46 爬爬QQ 阅读(843) 评论(0) 推荐(0)
摘要:1.创建爬虫 1 cmd-cd desktop scrapy startproject top250 View Code 2.修改访问表头UA 将setting文件里的USER_AGENT和COOKIES_ENABLED前面的#去掉 3.定义item容器 1 # -*- coding: utf-8 阅读全文
posted @ 2020-03-13 20:15 爬爬QQ 阅读(438) 评论(0) 推荐(0)
摘要:1 import pymysql 2 user=input("username:") 3 pwd=input("password:") 4 conn=pymysql.connect(host="localhost",user="%s"%user,password="",database="db1") 阅读全文
posted @ 2020-03-13 14:39 爬爬QQ 阅读(109) 评论(0) 推荐(0)
摘要:导出现有数据库数据: mysqldump -u用户名 -p密码 数据库名称 >导出文件路径 # 结构+数据 mysqldump -u用户名 -p密码 -d 数据库名称 >导出文件路径 # 结构 !!!注意:()一定要用英文半角 1 /* 2 Navicat Premium Data Transfer 阅读全文
posted @ 2020-03-13 13:31 爬爬QQ 阅读(167) 评论(0) 推荐(0)
摘要:基本框架( mysql+pymysql://<username>:<password>@<host>/<dbname>[?<options>]举例 engine=create_engine("mysql+pymysql://root:@localhost:3306/db2?charset=utf8" 阅读全文
posted @ 2020-03-12 15:57 爬爬QQ 阅读(481) 评论(0) 推荐(0)
摘要:1.单行和多行一样的方式:Ctr+/(前提是选中需要注释的代码) 2.输入''' '''或者""" """,将要注释的代码插在中间 3.mysql多行用/*开头 */结尾 阅读全文
posted @ 2020-03-12 14:57 爬爬QQ 阅读(151) 评论(0) 推荐(0)
摘要:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple +模块名 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade +模块名 pip install timeou 阅读全文
posted @ 2020-03-12 12:27 爬爬QQ 阅读(266) 评论(0) 推荐(0)
摘要:1 #TempConvert.py 2 while True: 3 TempStr = input("请输入带有符号的温度值: ") 4 if TempStr[-1] in ['F', 'f']: 5 C = (eval(TempStr[0:-1]) - 32)/1.8 6 print("转换后的温 阅读全文
posted @ 2020-03-11 21:54 爬爬QQ 阅读(173) 评论(0) 推荐(0)
摘要:1 /*DELIMITER $$ 2 3 CREATE FUNCTION `db1`.`generateUserName` () RETURNS varchar(255) CHARSET utf8 DETERMINISTIC -- 创建函数generateUserName() RETURNS 返回值 阅读全文
posted @ 2020-03-11 16:40 爬爬QQ 阅读(523) 评论(0) 推荐(0)