
python
文章平均质量分 67
wifi连不上
好看|有趣|有料的数据分析师
展开
-
时间序列处理
# -*- coding: utf-8 -*-"""Created on Sun Mar 27 22:56:24 2022@author: wuxian"""import pandas as pdimport datetimeimport numpy as np(datetime.date.today()).strftime('%Y-%m-%d')#H:小时 D:天 M:月#times #2016 Jul 7/1/2016 2016-07-01 2016/07/01pd.date原创 2022-04-28 18:21:52 · 406 阅读 · 0 评论 -
collections部分模块使用方法
from collections import Counterfrom collections import Counters = "hello-python-hello-world"a = Counter(s)print(a)# 结果 Counter({'-': 3, 'd': 1, 'e': 2, 'h': 3, 'l': 5, 'n': 1, 'o': 4, 'p': 1, 'r': 1, 't': 1, 'w': 1, 'y': 1})dict(a)#对键或者值排序 用sorted原创 2022-04-28 16:39:05 · 248 阅读 · 0 评论 -
分别用mysql,python查询日期期间连续天数,并求出最大连续天数
1、 首先给出表结构:给出两种处理方法:第一种利用参数解决:set @a := (SELECT max(日期) FROM `sheet1`);set @b :=1;set @c :=1;SELECT riqi 区间最小日期,DATE_ADD(riqi,INTERVAL rank-1 day) 区间最大日期,rank '连续区间的天数' from(SELECT @b :=if(DATEDIFF(@a,日期)=1,@b+1,1) as rank,@a:=日期 as 'riqi'from原创 2021-04-10 14:46:09 · 1242 阅读 · 2 评论 -
python中两个字符串日期如何相减,并利用apply()处理df自定义函数
# -*- coding: utf-8 -*-"""Created on Mon Apr 12 14:04:48 2021@author: wuxian"""from datetime import datetimedef date_diff(start_date,end_date): format_pattern = "%Y-%m-%d" # 将 'str' 时间通过格式化模式转化为 'datetime.datetime' 时间戳, 然后再进行比较 differenc原创 2021-04-12 14:33:50 · 2163 阅读 · 2 评论 -
python读取.csv 大文件的解决办法(iterator=true)
import pandas as pdimport datetimeimport warningswarnings.filterwarnings('ignore')#数据导入#调查日期today = datetime.date.today() searchdate = datetime.datetime.strftime(today, "%Y-%m-%d") path = r'C...原创 2020-04-04 17:38:21 · 3924 阅读 · 1 评论 -
python pip升级出错的解决办法
1、升级pip的常规操作python -m pip install --upgrade pip 又或者pip install -U pip结果依旧是报错结果想到卸载重新安装,但是结果依旧是较低版本的python -m pip uninstall pippython -m ensurepip --default-pippip --version结果试了,it works!eas...原创 2020-03-21 13:31:44 · 239 阅读 · 0 评论 -
将多个sheet合并成一个sheet导出,将多个dataframe导出至多个sheet
# -*- coding: utf-8 -*-"""Created on Mon Jan 20 13:02:27 2020@author: twx253"""import xlrdimport pandas as pdfrom pandas import DataFramefrom openpyxl import load_workbookexcel_name = 'C:...原创 2020-01-20 13:54:12 · 882 阅读 · 0 评论 -
百度图片爬虫demo
# -*- coding: utf-8 -*-"""Created on Wed Dec 11 17:27:29 2019@author: wuxian"""# -*- coding: utf-8 -*- import jsonimport itertoolsimport urllibimport requestsimport osimport reimport sys...原创 2019-12-30 14:22:27 · 138 阅读 · 0 评论 -
利用selenium实现动态网页的爬取
import refrom selenium import webdriverfrom selenium.webdriver.chrome.options import Options# 通过获取关键字职位数量def numberPositionsByKeyword(searchWord): # 创建chrome参数对象 chrome_options = Options(...原创 2019-12-26 16:27:14 · 384 阅读 · 0 评论 -
如何正确将python的DataFrame格式数据导入到mysql数据库
如何正确将DataFrame格式数据导入到mysql数据库读取数据库的操作和将数据写入到数据库还是有点不一样的将DataFrame格式数据导入到mysql数据库,采用create_engine()方法:from sqlalchemy import create_engine# create_engine('mysql+pymysql://用户名:密码@主机/库名?charset=utf8'...原创 2019-09-23 18:19:54 · 9591 阅读 · 4 评论 -
python基本语法练习
# -*- coding: utf-8 -*-"""Created on Tue Jun 11 14:27:05 2019@author: wuxian"""list6 = [1,5,2,8,10,13,17,4,6]result = []for i in list6: y = i ** 2 + 1 result.append(y)print(result)...原创 2019-09-22 17:40:30 · 241 阅读 · 0 评论 -
收入预测分析_practice
"""Created on Tue Jun 4 17:40:28 2019@author: wuxian"""import pandas as pdimport numpy as npimport seaborn as snsimport matplotlib.pyplot as plt##数据读取income = pd.read_excel(r'C:\Users\wuxia...原创 2019-09-22 17:38:26 · 355 阅读 · 0 评论 -
【机器学习实战】8_dimensionality_reduction代码《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
降维(主成分分析和因子分析)# -*- coding: utf-8 -*-"""Created on Fri Feb 1 16:21:14 2019@author: Administrator"""import matplotlib.pyplot as pltimport osimport numpy as npPROJECT_ROOT_DIR = 'E:\wuxian ...原创 2019-09-22 17:34:28 · 218 阅读 · 0 评论 -
【机器学习实战】9_deeplearning《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
深入学习入门# -*- coding: utf-8 -*-"""Created on Tue Feb 12 17:33:43 2019@author: Administrator"""# To support both python 2 and python 3from __future__ import division, print_function, unicode_lit...原创 2019-09-22 17:30:56 · 223 阅读 · 0 评论 -
【机器学习实战】7_集成学习_随机森林代码《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
集成学习_随机森林# -*- coding: utf-8 -*-"""Created on Wed Jan 30 10:02:50 2019@author: Administrator"""import matplotlib.pyplot as pltimport osimport numpy as npPROJECT_ROOT_DIR = 'E:\wuxian python...原创 2019-09-22 17:28:06 · 258 阅读 · 0 评论 -
【机器学习实战】6_decision_trees代码《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
decision_trees(iris_dataset)# -*- coding: utf-8 -*-"""Created on Mon Jan 28 15:35:48 2019@author: Administrator"""from sklearn.datasets import load_irisfrom sklearn.tree import DecisionTreeCl...原创 2019-09-22 17:10:34 · 280 阅读 · 0 评论 -
【微信】利用python分析微信好友各维度信息
想要知道你的微信好友性别分布嘛,想知道盆友分布在全国哪个省、哪个城市嘛,想要知道盆友喜欢什么嘛(签名),快来看看吧原创 2019-07-02 19:21:51 · 329 阅读 · 0 评论 -
【微信】利用python实现微信好友防撤回、消息监控
# -*- coding: utf-8 -*-"""Created on Fri Jun 21 12:09:43 2019@author: wuxian"""import sysimport os, re, shutil, time, collections, jsonfrom html.parser import HTMLParserfrom xml.etree impor...转载 2019-07-03 10:04:10 · 1437 阅读 · 0 评论 -
【爬虫实战】01利用python爬虫并进行数据分析(链家 爬虫)
爬虫实战01——利用python爬虫并进行数据分析爬取链家二手房相关信息并进行数据分析 {https://sh.lianjia.com/ershoufang/pg}一、爬虫部分背景需求来源于生活大数据时代来临,数据就是核心,数据就是生产力,越来越多的企业开始注重收集用户数据,而爬虫技术是收集数据的一种重要手段python版本:3.6.5 ,系统环境是windows,工具包:requ...原创 2019-06-27 20:05:06 · 12993 阅读 · 16 评论 -
【自动邮件】如何利用python自动发邮件(附件excel发送)
自动发送邮件可以将常规化得需求自动化,解放双手做更多有意义的事情原创 2019-07-03 19:46:37 · 1602 阅读 · 0 评论 -
【机器学习实战】1_GDP预测案例代码《Hands-On Machine Learning with Scikit_Learn &TensorFlow》
# -*- coding: utf-8 -*-"""Created on Fri Dec 14 13:45:58 2018@author: Administrator"""#import matplotlibimport matplotlib.pyplot as pltimport numpy as npimport pandas as pdimport sklearn#f...原创 2019-07-12 18:50:57 · 1592 阅读 · 3 评论 -
【机器学习实战】2_predict_median_house_values代码《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
# -*- coding: utf-8 -*-"""Created on Mon Dec 17 14:53:17 2018@author: Administrator"""#from __future__ import division,print_fuction,unicode_literals#os 模块提供了非常丰富的方法用来处理文件和目录。import os#impor...原创 2019-07-15 20:02:10 · 505 阅读 · 0 评论 -
【爬虫实战】【微信】如何利用python爬取APP评论-本文以ios爬取微信评论
# -*- coding: utf-8 -*-"""Created on Tue Jul 2 16:26:50 2019@author: wuxian"""#完整程序如下:import requestsimport redef getHTMLText(url): try: r = requests.get(url) r.raise_f...转载 2019-07-16 10:08:48 · 1121 阅读 · 0 评论 -
python实战-echarts-关系型图(无向图)可视化
# -*- coding: utf-8 -*-"""Created on Wed Jul 17 18:32:43 2019@author: wuxian"""from pyecharts import Graph nodes = [{"name": "结点1", "symbolSize": 1}, {"name": "结点2", "symbolSize": 2...原创 2019-07-25 15:09:43 · 2537 阅读 · 0 评论 -
【机器学习实战】3_Classification代码《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
手写数字图片分类# -*- coding: utf-8 -*-"""Created on Tue Dec 25 13:43:39 2018@author: Administrator"""#from sklearn.datasets import fetch_mldataimport numpy as npimport scipy.io as ioimport osimpor...原创 2019-09-22 16:59:18 · 396 阅读 · 0 评论 -
【机器学习实战】4_Training_Linear_Model代码《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
训练线性模型# -*- coding: utf-8 -*-"""Created on Mon Jan 7 19:32:56 2019@author: Administrator"""'''Linear regression using the Normal Equation'''# =================================================...原创 2019-09-22 17:02:56 · 222 阅读 · 0 评论 -
【机器学习实战】5_SVM代码《Hands-On Machine Learning with Scikit-Learn&TensorFlow》
SVM# -*- coding: utf-8 -*-"""Created on Wed Jan 16 16:30:13 2019@author: Administrator"""from sklearn.svm import SVCfrom sklearn import datasetsimport numpy as npimport matplotlib.pyplot as...原创 2019-09-22 17:05:12 · 270 阅读 · 0 评论 -
如何根据具体地址获取经纬度
根据具体地址获取经纬度通过python调用高德地图接口,返回经纬度代码如下:import xlrdimport requestsimport json# 设置路径path = './lj_distinct_data_analysis.xlsx'# 打开execlworkbook = xlrd.open_workbook(path)# 输出Excel文件中所有sheet的名字...原创 2019-07-02 13:21:13 · 5830 阅读 · 0 评论