利用Python一键爬取上海二手房信息

基于python的二手房数据爬取与分析 为了更清晰地查看具体的重复值,我们借助print(data[data.duplicated()])打印出了重复值的详细信息,为了确保数据的准确性和简洁性,我们采用了data.drop_duplicates(inplace=True)方法来删除当前的重复项。然后,通过Xpath表达式定位到需要提取信息的节点,并使用相应的方法提取出所需的信息,如房屋地址、名称、房间数目、朝向、其他信息、总价、每平方的价钱和建造年份等。它将复杂的数据转化为易于理解的视觉元素,帮助人们发现数据中的模式、趋势和关系。 阅读详情

此次项目使用Scrapy-Redis分布式爬取,请自备代理ip

仪表板显示

在这里插入图片描述

项目背景

我在上海工作的时候有朋友就发信息问我上海一些二手房的价格情况,作为一个二愣子我只知道上海哪个区贵,但是不知道具体是什么价格,所以我就想着爬取一下上海的二手房。

从政策上来看,自从2016年国家喊出了“ 房主不炒 ”的口号之后中国的放假就出现了明显的降温。
2019年国家为了“救市”又宣布了几条政策:

1,政府不再垄断住房供应,缓解了开发商的资金压力,新房销售价格降低,导致新房市场火热而二手房市场冷清。
2,调整公积金贷款利率,提高了二房的房贷利率,打击市场投机需求。
3,鼓励租售并举,鼓励以住房租赁为主营业务的企业买房。
4,居住证降低申请门槛新政,让落户买房更加容易。
5,农民购房有补助,帮助农民工朋友们省去一部分买房成本。

从经济上来看,2020年上半年上海人均可支配收入以 36577 元笑傲全国,同比增长3.64%。看似美丽的数值背后,隐藏着多少被平均的普通老百姓。
从社会上来看,2019 年我国人口出生率创下1949年以来的最低值,即使在2016 年开放二胎政策以来,人口出生率也没有大幅提高。
从技术上来看,中国造楼能力世界第一!“基建狂魔”岂是浪得虚名!

分析目的

1,2020年上半年上海二手房整体挂牌量及均价走势如何?
2,目前上海二手房价位、房源有何特点?
3,上海各区县的挂牌情况,找出抛压最大的区域

数据清洗

首先我们看一下爬取的数据。维度不是太多,但是有些列我们可以拆分,例如地区、所在楼层、抵押信息等。

在这里插入图片描述

在对数据进行清洗前我们可以使用pandas_profiling进行快速的统计分析。

import pandas_profiling
pandas_profiling.ProfileReport(data).to_file("./report/html")

在这里插入图片描述

根据报告内容我们可以看到本次数据总共有 37491 行,20 列,存在 7行重复,重复占比小于 0.1%,报告继续下拉可以看到每一列的统计情况。
我们需要清洗的几点:
1,把重复的去掉
2,替换空(None)值
3,将地区,房屋户型,所在楼层,抵押信息进行切分合并
4,转换数据类型
5,删除多余字符
6,由于爬取时出现的错误,对价格列进行重新赋值
7,去掉异常数据

 #如果有重复值,则保留第一个
data.drop_duplicates(keep='first', inplace=True)

# 替换None
data = data.applymap(lambda x: '暂无数据' if x == 'None' else x)

# 切分地区、房屋户型、所在楼层、抵押信息后删除原列,将拆分出的新列合并至原data
data = pd.concat([data, data['地区'].str.extract(pat='(?P<区>.*?)\s(?P<镇>.*?)\s(?P<环>.*)'),
                  data['房屋户型'].str.extract(
                      pat='(?P<室>\d+)室(?P<厅>\d+)厅(?P<厨>\d+)厨(?P<卫>\d+)卫'),
                  data['所在楼层'].str.extract(
                      pat='(?P<所处楼层>.+)\(共(?P<总层数>\d+)层\)'),
                  data['抵押信息'].map(lambda x:x.strip()).str.extract(pat='(?P<有无抵押>.{1})抵押(?P<抵押情况>.*)?')], axis=1)

data.drop(['地区', '所在楼层', '抵押信息'], axis=1, inplace=True)
data['区'] = data['区']+'区'
# 去除建筑面积后面的平米单位,并转为float
data['建筑面积'] = data['建筑面积'].map(lambda x: float(x[:-1
利用Python爬虫和Tableau分析链家网二手房信息 1、明确分析的目标和思路 目的:近年来,房价时时刻刻牵动着广大老百姓的心,尤其是急需买房的刚需族和二胎家庭的置换族。本文希望通过对上海市中心城区二手房信息的分析,能够对房价和地理位置、房龄等因素的关系有一定的掌握。 分析思路:通过python爬取链家网二手房信息,经过数据清洗、规约等处理后,导入Tableau软件,进行可视化分析,得出结论。   2、爬取链家网二手房信息 以上海市中心城区... 阅读详情

相关推荐

73 | 基于Python的上海二手房数据爬取及分析

随着中国房地产市场的快速发展,二手房交易日益活跃,成为了城市居民购房的重要选项之一。上海作为中国经济的中心,其二手房市场尤为繁荣,吸引了众多购房者的关注。为了深入理解上海二手房市场的现状,分析房价走势、区域分布、房屋特征等因素,本项目选取链家网上海地区的二手房信息作为数据来源。链家网是中国领先的房地产在线平台,拥有丰富的房源信息,是进行此类分析的理想数据源。

微信号:RunsenLiu 1828

基于爬虫爬取某居客二手房网站中上海二手房的数据+机器学习方法进行数据分析(完整源码).zip

【资源说明】 1、该资源内项目代码都是经过测试运行成功,功能正常的情况下才上传的,请放心下载使用。 2、适用人群:主要针对计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、数学、电子信息等)的同学或企业员工下载使用,具有较高的学习借鉴价值。 3、不仅适合小白学习实战练习,也可作为大作业、课程设计、毕设项目、初期项目立项演示等,欢迎下载,互相学习,共同进步!

不用FFmpeg!纯前端实现RTSP直播的3种现代方案对比(WebSocket/Wasm/WebCodecs)

本文深入探讨了纯前端实现RTSP直播的三种现代技术方案:WebSocket代理转发、Wasm解码和WebCodecs硬解。通过详细的架构设计、性能实测数据和兼容性分析,帮助开发者在安防监控、智慧城市等场景中选择最佳方案,实现低延迟、高效率的视频流处理。

lilh34434的博客 236

微信小程序PC端数据抓取实战:用Fiddler Everywhere + OkHttp快速搞定接口分析

本文详细介绍了如何在PC端使用Fiddler Everywhere和OkHttp进行微信小程序接口抓取与分析。从环境配置、请求捕获到代码复现,提供了一套完整的解决方案,帮助开发者高效完成数据抓取任务,特别适合需要分析微信小程序数据交互的开发者。

weixin_30838873的博客 349

Android Keystore与StrongBox实战:密钥存储与使用全指南

在移动应用安全领域,加密密钥的存储与管理往往比加密算法本身更关键。如果密钥以硬编码或明文文件形式存在,即使使用AES、RSA等强加密算法,攻击者通过反编译即可轻易突破。Android系统从6.0开始提供Keystore系统,将密钥生成与运算隔离在安全环境中;TEE(可信执行环境)和StrongBox硬件安全模块则进一步把密钥锁进硬件边界,实现“密钥材料不可导出”的防护目标。理解KeyStore的原理与能力,不仅能让开发者在合规审查、上架审核中拿出有力依据,还能在不依赖第三方SDK的前提下,通过Code Le

weixin_29164185的博客 289

WPS专业版自带字体

WPS专业版其中一个好处就是自带了部分有版权的字体,就算你安装了没买授权,他也会给你在系统里面安装上这些字体,至于没授权继续用合不合规我不知道。但是带来的实实在在的好处就是有些子他支持的全啊。 /usr/share/fonts/wps-office/FZWBK.TTF: 方正魏碑_GBK,FZWeiBei\-S03:style=Regular /usr/share/fonts/wps-office/FZFSK.TTF: 方正仿宋_GBK,FZFangSong\-Z02:style=Regular /us

chenqioulin的博客 5734

Unity音游开发全指南:模板与免费资源高效构建节奏游戏

**粒子特效** | [Universal VFX](https://assetstore.unity.com/packages/vfx/particles/universal-vfx-159182) | 免费视觉特效 || **UI素材** | [Game UI Pack](https://assetstore.unity.com/packages/2d/gui/game-ui-pack-86908) | 现代风格UI元素 |**音游开发的黄金法则**:完美的节奏游戏是音乐与游戏的和谐统一。

Loving_enjoy的博客 737

secureCRT 破解方法

3、输入注册信息打开keygen.exe,点击path,选择SecureCRT的安装目录(例如D:\VanDykeSoftware\Clients)的securecrt.exe打开,继续下一步打开LicenseHelper.exe,如下。1、注册SecureCRT9.1打开keygen.exe,出现以下问题(没有关掉安全防护,一双击打开,Windows会自动识别keygen.exe为bingdu并删除)打开桌面SecureCRT,此界面不输入内容,直接点击下一步。2、存储配置文件夹(可以默认安装)

逆水行舟 1万+

基于VisionMaster实现数据实时存储至MySQL (二)

摘要:之前的分享主要聚焦于简单的一维数据实时存储。但在做缺陷检测项目时,情况往往更加复杂:一张检测图像中可能同时存在多个缺陷,每个缺陷都有一组独立的核心参数(如质心、长短轴、面积等)。如何在 MySQL 中记录这些成组出现的缺陷数据,而不只是简单的单条记录?

haier123888的博客 230

基于LSTM GRU RNN的交通流量预测-完整数据代码

基于LSTM GRU RNN的交通流量预测-完整数据代码

926

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

上一篇: Wireshark抓包的妙用
下一篇: 你对于ORM框架中的SQLAlchemy真的了解吗?
python程序员小'鹏
博客等级 码龄6年 165粉丝 87原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址