![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python基础
文章平均质量分 86
weixin_43139613
这个作者很懒,什么都没留下…
展开
-
superset在linux和windows下的安装和部署
前言Superset 是 Airbnb开源的数据探查与可视化平台,是个轻量级的BI工具,开发者可以在其开源代码上根据需要进行二次开发。最近在探索数据分析平台的应用,就来试一试,然而superset更新迭代的速度太快,里面也有太多的坑,花了两天的时间踩完,下面就把流程以及相应的坑分享~superset github地址:https://github.com/apache/incubator-superset官方文档:http://superset.apache.org/installation.html原创 2020-10-27 18:56:28 · 363 阅读 · 0 评论 -
天天基金爬虫
import requestsfrom requests.exceptions import ConnectionErrorfrom pyquery import PyQuery as pqimport operatorfrom functools import reduceimport reimport jsonimport pandas as pdimport numpy as npheaders = { 'Host':'club.jd.com', '原创 2020-08-04 15:28:49 · 960 阅读 · 0 评论 -
python按时间坐标预测销量
import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport matplotlib as mplimport datetimeimport warningswarnings.filterwarnings("ignore")import statsmodels.api as smfrom statsmodels.graphics.api import qqplotfrom statsmodels.ts转载 2020-07-30 17:55:27 · 387 阅读 · 0 评论 -
算年化利率的公式
def ap(p,n,r): i = 0 l = 0 s = 0 while i <= n: l = (s+p-i*p/n)*(r/12) i += 1 s += l return s #ap(3999,24,0.04)import matplotlib.pyplot as pltimp...原创 2020-04-15 18:06:41 · 577 阅读 · 0 评论 -
python操作Excel实用技巧
1.使用“|””对字符串进行分隔,然后可以筛选出保函有的品类m = "|".join(list(pbpd['品牌信息']))uhpb['种类'] = uhpb['商品信息'].str.findall(m)2.多张Excel合成为一张,并加入A列以区分dfs = []p = os.listdir(r'D:\xml\............')for i in range(len(p)...原创 2020-03-31 15:19:00 · 139 阅读 · 0 评论 -
数据归一化处理方法
最值归一化 Normalization# 最值归一化 Normalizationimport numpy as npx = np.random.randint(1,100,size=100)#进行最值归一化x = (x - np.min(x)) / (np.max(x) - np.min(x))#多维数组的最值归一化X = np.random.randint(1,100,(50,...原创 2020-02-09 18:15:53 · 1144 阅读 · 0 评论 -
K近邻算法--鸢尾花数据集
from sklearn import datasetsiris = datasets.load_iris()x = iris.datay = iris.targetfrom sklearn.model_selection import train_test_splitx_train, x_test,y_train, y_test = train_test_split(x,y,te...原创 2020-02-09 17:11:10 · 449 阅读 · 0 评论 -
selenium爬虫丁香医生实时播报
from pyecharts.faker import Fakerfrom pyecharts import options as optsfrom pyecharts.charts import Mapfrom selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdri...原创 2020-02-01 14:37:18 · 1307 阅读 · 0 评论 -
实时的可视化疫情地图
多难兴邦,希望疫情尽快结束,等待春暖花开from pyecharts.faker import Fakerfrom pyecharts import options as optsfrom pyecharts.charts import Mapfrom selenium import webdriverfrom selenium.webdriver.common.by import By...原创 2020-01-31 12:47:11 · 14084 阅读 · 6 评论 -
pandas生意参谋数据处理
import os import pandas as pdhhye = os.listdir(r'C:\Users\18352\Desktop\Python\read_Excel\01-天猫行业数据分析')for k in range(len(hhye)): wwdu = os.listdir(r'C:\Users\18352\Desktop\Python\read_Excel...原创 2020-01-15 16:03:14 · 719 阅读 · 0 评论 -
简单层的实现
class MulLayer: def __init__(self): self.x = None self.y = None def forward(self,x,y): self.x = x self.y = y out = x*y return out ...原创 2019-12-27 18:05:46 · 398 阅读 · 0 评论 -
天猫超市requests爬虫
import pymongoimport requestsfrom requests.exceptions import ConnectionErrorfrom pyquery import PyQuery as pqimport timeclient = pymongo.MongoClient('localhost')db = client['tmmc']#PROXY_POOL...原创 2019-12-23 11:20:41 · 988 阅读 · 0 评论 -
30行Python代码爬取LOL全英雄皮肤
受到~wangweijun的20行Python代码爬取王者荣耀全英雄皮肤的启发我去试试同样的方法爬取LOL皮肤,果然方法大同小异,毕竟都是腾讯系的首先进入LOL官网进入资料库获取全英雄的详细列表,包括ID、绰号、英文名、中文名等等url = 'https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'herol...原创 2019-12-20 14:17:04 · 836 阅读 · 1 评论 -
python爬虫天猫超市
# -*- coding: utf-8 -*-from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support import expected_condi...原创 2019-12-19 13:30:27 · 1125 阅读 · 0 评论 -
爬虫天猫超市失败
# -*- coding: utf-8 -*-"""Created on Fri Dec 6 09:33:51 2019@author: 18352"""from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys impo...原创 2019-12-13 14:11:04 · 316 阅读 · 0 评论 -
selenium的基础用法
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support import expected_conditions as ECfrom seleniu...原创 2019-12-05 17:14:36 · 194 阅读 · 0 评论 -
pandas清洗Kobe数据
清洗Kobe数据import pandas as pdimport matplotlib.pyplot as pltimport matplotlib.cm as cmimport numpy as npraw = pd.read_csv('.\data\kobe_data.csv')print(raw.shape)kobe = raw[pd.notnull(raw['shot_...原创 2019-11-05 23:25:20 · 246 阅读 · 0 评论 -
scikit-learn__03.2__Regression-Forests
Supervised Learning In-Depth: Random Forests(随机森林)以前,我们看到了一个强大的判别分类器** Support Vector Machines **。在这里,我们将探讨激励另一个强大的算法。 这是一种称为“随机森林”的非参数算法。%matplotlib inlineimport numpy as npimport matplotlib.pyp...翻译 2019-11-05 17:16:52 · 225 阅读 · 0 评论 -
scikit-learn__03.1__Classification-SVMs
深度监督学习:支持向量机之前,我们介绍了有监督的机器学习。有许多监督学习算法可用。 在这里,我们将简要介绍最强大且有趣的方法之一:支持向量机(SVM)。%matplotlib inlineimport numpy as npimport matplotlib.pyplot as pltfrom scipy import statsplt.style.use('seaborn')...翻译 2019-11-05 16:54:19 · 209 阅读 · 0 评论 -
scikit-learn__02.2__Basic-Principles
机器学习的基本原则在这里,我们将深入探讨机器学习的基本原理,以及如何通过Scikit-Learn API使用它们。在简要介绍scikit-learn的Estimator对象之后,我们将介绍有监督的学习,包括分类和回归问题,以及无监督的学习,包括降维和聚类问题。%matplotlib inlineimport numpy as npimport matplotlib.pyplot as p...翻译 2019-11-05 14:51:28 · 222 阅读 · 0 评论 -
python将Excel导入SQL server 中
import xlrdimport pymssqlimport datetime # 连接本地sql server 地址 用户名 密码 数据库conn = pymssql.connect("192.168.**.***", "sa", "********", "*****")# 建立cursor...原创 2019-10-24 11:58:22 · 842 阅读 · 0 评论 -
python淘宝爬虫存入MonggoDB
# -*- coding: utf-8 -*-#定向爬取淘宝商品页面import requestsimport reimport pymongoclient = pymongo.MongoClient('localhost')db = client['taobao']headers = { 'Cookie':'thw=c9B567C18', 'Ho...原创 2019-10-23 09:43:26 · 264 阅读 · 0 评论 -
简单爬取知乎热榜到mongodb
import pymongoimport requestsfrom requests.exceptions import ConnectionErrorfrom pyquery import PyQuery as pqclient = pymongo.MongoClient('localhost')db = client['zhihu']base_url = 'https://...原创 2019-10-21 14:13:54 · 165 阅读 · 0 评论 -
使用代理把搜索结果导入mongo
# -*- coding: utf-8 -*-"""Spyder EditorThis is a temporary script file."""import pymongoimport requestsfrom requests.exceptions import ConnectionErrorfrom pyquery import PyQuery as pqclient...原创 2019-10-20 09:59:34 · 167 阅读 · 0 评论 -
requests爬虫搜狗微信公众号
# -*- coding: utf-8 -*-"""Spyder EditorThis is a temporary script file."""import requestsfrom requests.exceptions import ConnectionErrorfrom pyquery import PyQuery as pq#keyword = '风景'bas...原创 2019-10-19 21:40:21 · 325 阅读 · 0 评论 -
lambda x if转换的用法
list(map(lambda x:x if x%2 == 0 else x+1000 if x == 3 else x+1,[i for i in range(20)]))[0, 2, 2, 1003, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20]如果能被2整除就是本身,如果 = 3 就加1000 否则就加一...原创 2019-06-18 11:39:26 · 4467 阅读 · 0 评论 -
python爬虫——链家苏州成交房价
# -*- coding: utf-8 -*-import bs4 import requestsdef open_url(url):# url = 'https://su.lianjia.com/chengjiao/gongyeyuan/pg1/' hd = {} hd['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1) ...原创 2019-02-21 17:09:35 · 346 阅读 · 0 评论 -
深度学习-2
Jupyter Notebook深度学习2最后检查: 上星期二09:41(自动保存)Current Kernel LogoPython 3FileEditViewInsertCellKernelWidgetsHelpimport sys , osimport sys , ossys.path.append(os.pardir)sys.path.append(os....原创 2019-09-16 18:03:24 · 999 阅读 · 0 评论 -
python--scipy--2离散概率分布:二项分布
今天才知道原来文件名和库的名字不能一样了还有这样的bug#导入包#数组包import numpy as np#绘图包import matplotlib.pyplot as plt#统计计算包的统计模块from scipy import stats'''arange用于生成一个等差数组,arange([start, ]stop, [step, ]使用见文档:https://d...原创 2019-04-09 15:16:49 · 1689 阅读 · 0 评论 -
python--scipy--1离散概率分布:伯努利分布
#导入包#数组包import numpy as np#绘图包import matplotlib.pyplot as plt#统计计算包的统计模块from scipy import stats'''arange用于生成一个等差数组,arange([start, ]stop, [step, ]使用见文档:https://docs.scipy.org/doc/numpy/referen...原创 2019-04-09 14:37:46 · 1799 阅读 · 0 评论 -
链家二手房爬虫和获取经纬度
# -*- coding: utf-8 -*-"""Created on Mon Mar 25 10:10:22 2019@author: """# -*- coding: utf-8 -*-import bs4 import requestsimport time#引入time,计算下载时间import socketfrom urllib import errordef...原创 2019-03-28 16:17:06 · 3512 阅读 · 0 评论 -
链家二手房在售爬虫
# -*- coding: utf-8 -*-"""Created on Mon Mar 25 21:13:13 2019@author: 盗号"""# -*- coding: utf-8 -*-"""Created on Mon Mar 25 10:10:22 2019@author: zhang-peng"""# -*- coding: utf-8 -*-impor...原创 2019-03-25 22:05:33 · 521 阅读 · 0 评论 -
sigmoid函数
# -*- coding: utf-8 -*-import numpy as npx = np.array([-1,1,2])y = x>0print(y)print(y.astype(np.int))#阶跃函数图像import matplotlib.pyplot as pltdef step_function(x): return np.array(x>...原创 2019-02-25 13:27:30 · 188 阅读 · 0 评论 -
人鬼名单
import numpy as npimport pandas as pdjinglist = [ 'hylr','dsjp','cvmm', 'yusv','ufpj','vujn', 'bomk','mwho','dmfu', 'dcqu','jymu','waff', ...原创 2019-01-29 16:21:12 · 183 阅读 · 0 评论 -
循环代码的优化
import timetime1 = time.time() a = ""for i in range(1000000): a += "sxt"time2 = time.time()print("运算时间:"+str(time2-time1))time3 = time.time()li = []for i in range(1000000 ): li.appe...原创 2018-11-18 23:30:29 · 535 阅读 · 0 评论 -
字典的解剖
a = ['名字','年龄','性别']b = ['Ken','18','男']c = dict(zip(a,b))print(c)s = ''print(s.center(60,'-'))print(c.items())print(s.center(60,'-'))print(c.values())print(s.center(60,'-'))print(c.keys(...原创 2018-11-18 23:27:30 · 125 阅读 · 0 评论 -
修改字符串
import ios = "Hello, Ken"sio = io.StringIO(s)sio.seek(7)sio.write('may')print(sio.getvalue())Hello, may原创 2018-11-18 23:26:07 · 224 阅读 · 0 评论 -
format基本用法
a = "名字是:{0},年龄:{1}。"print(a.format('Ken','18'))b = "我的名字时:{0},喜欢数字{1:*^8}"print(b.format('Ken','66'))c = "我的名字时:{0},喜欢数字{1:*>8}"print(c.format('Ken','66'))d = "我的名字时:{0},喜欢数字{1:*<8}"p...原创 2018-11-18 23:24:45 · 166 阅读 · 0 评论 -
python--scipy--3离散概率分布:几何分布
#导入包#数组包import numpy as np#绘图包import matplotlib.pyplot as plt#统计计算包的统计模块from scipy import stats'''arange用于生成一个等差数组,arange([start, ]stop, [step, ]使用见文档:https://docs.scipy.org/doc/numpy/refere...原创 2019-04-09 15:30:41 · 1362 阅读 · 0 评论 -
python--scipy--4离散概率分布:泊松分布
#导入包#数组包import numpy as np#绘图包import matplotlib.pyplot as plt#统计计算包的统计模块from scipy import stats'''arange用于生成一个等差数组,arange([start, ]stop, [step, ]使用见文档:https://docs.scipy.org/doc/numpy/refere...原创 2019-04-09 15:58:58 · 3282 阅读 · 0 评论