本文是数据可视化的第二篇练习文,目的是承接上一篇中国全国各省结婚率和离婚率数据可视化

该篇文章主要使用的是Python数据可视化,用来分析北京地区从2002到2018年房价的趋势变化

为了方便读者理解,在写的篇幅中,不加入代码,所有代码放在最后的附录里。

一:加载数据以及相应的库包

二:检验数据

加载成功后,需要验证数据的正确性

三:数据处理

对于数据的处理,我们一般查看数据中的缺失值

以上6列数据具有缺失值。

然后我们计算数据中空列缺失值的个数

另外解释一下数据中各列值的含义

url:   the url which fetches the data

id:    the id of transaction

lng:      经

lat:       纬

cid:      community id

tradeTime:    the time of transaction

followers:     the number of people follow the transaction.

price:           the average price by square

square:        the square of house(1m*1m)

livingRoom:    the number of living room

drawingRoom:  the number of drawing room

kitchen:     the number of kitchen

bathroom:    the number of bathroom
constructionTime:        建造年代

floor:              the height of the house. I will turn the Chinese characters to English in the next version.

buildingType:               including tower( 1 ) , bungalow( 2 ),combination of plate and tower( 3 ), plate( 4 ).

renovationCondition:     including other( 1 ), rough( 2 ),Simplicity( 3 ), hardcover( 4 )

buildingStructure:         including unknow( 1 ), mixed( 2 ), brick and wood( 3 ), brick and concrete( 4 ),steel( 5 ) and steel-concrete composite ( 6 ).
ladderRatio: the proportion between number of residents on the same floor and number of elevator of ladder. It describes how many ladders a resident have on average.

elevator:                     have ( 1 ) or not have elevator( 0 )
fiveYearsProperty:       if the owner have the property for less than 5 years,

district列表中各区指代内容:

1:东城区
2:丰台区
3:亦庄
4:大兴区
5:房山
6:昌平区
7:朝阳区
8.海淀区
9.石景山
10:西城区
11:通州区
12门头沟
13:顺义区

查看各值的数量:

若空列数量占总过多或者不影响关键信息,可以直接删除空列

其中,

axis=1     删除   columns

axis=0    删除    rows

四、数据可视化

  • 北京(2002-2018)年房价总体走势图(单价)

  元/平方米

  • 北京房子总价与房屋面积之间的关系:

  • 北京各区房子总价与房屋面积之间的关系

  • 北京各区房价单价的中位数(元/平方米)

   可以看到西城最高,东城次之

  • 区域与房子单价之间的关系图(盒图)

  • 区域与房子单价之间的关系图(分类散点图)

  • 各区房价与总价之间的关系

    可以明显看到,朝阳区3千万以上好在比其它区多,西城次之,富人应该多集居在朝阳,西城,海淀

  • 北京各区房价的中位数

   中位数代表着普通百姓的消费能力,可以看到,西城,东城,海淀最高

  • 北京各区房子面积分布

   朝阳,昌平的大房比较多

  • 各区房子面积的中位数

    昌平居冠,西城最小

五、买房应该注意什么

  1.人们喜欢什么价位的房子

  可以发现1000万以下的房子followers比较多,说明这个段位以下的房子面向的人群最广

   2.地铁对房价的影响

   可以很明显的发现,各区周围有地铁的房子,比无地铁的房子,单价要高几千,其中海淀,门口沟,朝阳,房山影响很明显,说明这几个区居住的上班族多

  3.建造年代与房子单价的关系(单位:万/平方米)

  最近几年的房子以及老房普遍比新房贵,可能是区域的关系,因为老房多位于老城区,房价比较高

  4.建造年代与房子总价的关系(单位:百万/套)

  5.人们更喜欢什么楼层的房子

  可以看到5楼和6楼比较抢手

  6.五年产权对房价的影响

  可以看到政策的影线,没有到五年产权的房子单价普遍贵一些

六、总结

以上是使用Python对北京房价的数据可视化,可以发现一些有趣的信息。笔者准备使用热力图显示相应的信息,但是由于地图测绘法的关系,echarts.js的北京地图信息不能使用了,如果有谁知道其它工具的化可以给我留言,期望改进,比心!

附录

本文所有的代码:

# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory

import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))

# Any results you write to the current directory are saved as output.

import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns

file_path = "../input/lianjia/new.csv"

file_content = pd.read_csv(file_path,encoding='gbk')

file_temporary = pd.read_csv(file_path,encoding='gbk',index_col='tradeTime',parse_dates=True)

file_temporary.sort_index()

df2=pd.DataFrame(file_temporary.sort_index())

plt.figure(figsize=(30,6))
sns.lineplot(data=df2['price'],label='the trend of housing price in beijing')

df = pd.DataFrame(file_content)
with_missing_value = [col for col in df.columns if df[col].isnull().any()]

count_missing_null_column = (df.isnull().sum())

df = df.drop(with_missing_value,axis=1)

df['price'].shape

sns.regplot(x=df.loc[0:10000,'square'],y=df.loc[0:10000,'totalPrice'])

df_copy= df.copy()

df_copy.district[df.district==1]='Dongcheng'
df_copy.district[df.district==2]='Fengtai'
df_copy.district[df.district==3]='Yizhuang'
df_copy.district[df.district==4]='Daxing'
df_copy.district[df.district==5]='Fangshan'
df_copy.district[df.district==6]='Changping'
df_copy.district[df.district==7]='Chaoyang'
df_copy.district[df.district==8]='Haidian'
df_copy.district[df.district==9]='Shijingshan'
df_copy.district[df.district==10]='Xicheng'
df_copy.district[df.district==11]='Tongzhou'
df_copy.district[df.district==12]='Mentougou'
df_copy.district[df.district==13]='Shunyi'

sns.lmplot(x="square", y="totalPrice", hue="district", data=df_copy)

plt.figure(figsize=(30,6))
sns.swarmplot(x=df_copy.loc[0:10000,'district'],
y=df_copy.loc[0:10000,'price'])

plt.figure(figsize=(30,6))
sns.boxplot(x=df_copy.loc[0:10000,'district'], y=df_copy.loc[0:10000,'price'])

len=[]
for i in range(1,14):
len.append(df.price[df.district==i].median())
print (len)

plt.figure(figsize=(16,6))
sns.barplot(x=['Dongcheng','Fengtai','Yizhuang','Daxing','Fangshan','Changping',
'Chaoyang','Haidian','Shijingshan','Xicheng','Tongzhou','Mentougou'
,'Shunyi'
],y=len)

plt.figure(figsize=(20,6))
sns.swarmplot(x=df_copy.loc[0:10000,'district'],
y=df_copy.loc[0:10000,'totalPrice'])

total_len=[]
for i in range(1,14):
total_len.append(df.totalPrice[df.district==i].median())

print (total_len)
plt.figure(figsize=(16,6))
sns.barplot(x=['Dongcheng','Fengtai','Yizhuang','Daxing','Fangshan','Changping',
'Chaoyang','Haidian','Shijingshan','Xicheng','Tongzhou','Mentougou'
,'Shunyi'
],y=total_len)

plt.figure(figsize=(20,6))
sns.swarmplot(x=df_copy.loc[0:10000,'district'],
y=df_copy.loc[0:10000,'square'])

plt.figure(figsize=(20,6))
sns.boxplot(x=df_copy.loc[0:10000,'district'],
y=df_copy.loc[0:10000,'square'])

total_square=[]
for i in range(1,14):
total_square.append(df.square[df.district==i].median())

print (total_len)
plt.figure(figsize=(16,6))
sns.barplot(x=['Dongcheng','Fengtai','Yizhuang','Daxing','Fangshan','Changping',
'Chaoyang','Haidian','Shijingshan','Xicheng','Tongzhou','Mentougou'
,'Shunyi'
],y=total_square)

plt.figure(figsize=(20,6))
sns.regplot(x=df.loc[0:10000,'followers'],y=df.loc[0:10000,'totalPrice'])

pd_construct_time = pd.read_csv(file_path,encoding='gbk',index_col='constructionTime',parse_dates=True)

df_construct = pd.DataFrame(pd_construct_time)

plt.figure(figsize=(40,6))
sns.lineplot(data=df_construct["price"])

plt.figure(figsize=(40,6))
sns.lineplot(data=df_construct["totalPrice"])

plt.figure(figsize=(40,6))
sns.boxplot(x="constructionTime", y="totalPrice", data=df)

plt.figure(figsize=(40,20))
ax = sns.boxplot(x="district", y="price", hue="subway",data=df_copy, palette="Set3")

plt.figure(figsize=(40,20))
ax = sns.boxplot(x="district", y="price", hue="fiveYearsProperty",data=df_copy, palette="Set3")

plt.figure(figsize=(70,20))
ax = sns.boxplot(x="district", y="price", hue="buildingStructure",data=df, palette="Set3")

plt.figure(figsize=(50,6))
sns.boxplot(x=df.loc[0:10000,'floor'],y=df.loc[0:10000,'followers'])

first=[]
second=[]
for i,j in zip(df.floor,df.followers):
temp=i.split(" ")
if len(temp)==2:
first.append(temp[1])
second.append(j)

output = pd.DataFrame({
'floor':first,
'followers':second
})

output.to_csv('floor-followers.csv',index=False)

floor_price = pd.read_csv('floor-followers.csv')

df = pd.DataFrame(floor_price)

df_sorted=df.sort_values(by='floor')

plt.figure(figsize=(30,30))
sns.boxplot(x="floor",y="followers",data=df_sorted)

转载于:https://www.cnblogs.com/zhichun/p/11521852.html

北京房价信息(2002-2018)数据可视化相关推荐

  1. Python教你爬取某团烤肉店铺数据信息并实现数据可视化,吃货还是更多的(内含完整代码)

    [课 题]: Python爬取某团店铺数据信息并实现数据可视化 [课程亮点] 1.动态数据抓包演示 2.json数据解析 3.requests模块的使用 4.保存csv [环境介绍] python 3 ...

  2. 【Python】基于Python获取链家小区房价信息及其POI数据

    文章目录 1 简介 2 效果展示 3 分析网页 4 代码思路 5 完整代码 6 相关文章 1 简介 本来要先发在csdn上的,但是之前学弟催我给他公众号写点东西,我就把这篇博客首发在他的公众号上,现在 ...

  3. 数据挖掘工具分析北京房价 (一) 数据爬取采集

    一. 前言 房价永远是最让人头疼且激动的话题,尤其是在帝都,多少人一辈子都为了一套房子打拼.正好我也想用一个大家比较关心的话题作为案例,把目前我开发的这套软件进行一次完整的演练.从数据采集,到清洗,分 ...

  4. 数据挖掘工具分析北京房价 (一) 数据爬取采集(转)

    一. 前言 房价永远是最让人头疼且激动的话题,尤其是在帝都,多少人一辈子都为了一套房子打拼.正好我也想用一个大家比较关心的话题作为案例,把目前我开发的这套软件进行一次完整的演练.从数据采集,到清洗,分 ...

  5. 基于Python的招聘信息的大数据可视化分析系统

    1. 项目背景 互联网时代,网络已经完完全全渗透到我们的生活当中,成为我们生活当中的一部分,其中很多求职.找工作也不例外,因此,很多招聘平台,例如像赶集网.58同城.英才网.智联招聘.前程无忧等求职网 ...

  6. 获取网站上的旅游攻略信息,并作数据可视化

    1.爬取2023最新游记有什么好玩的地方-适合年轻人的旅游攻略-去哪儿攻略 (qunar.com) 1.导入相应的库 import requests import parsel import csv ...

  7. 数据可视化、信息可视化与知识可视化

    数据可视化.信息可视化与知识可视化 (2011-07-23 12:28:17) 标签: 校园 分类: 工作篇 数据可视化 简介 数据可视化是关于 数据 之视觉表现形式的研究:其中,这种数据的视觉表现形 ...

  8. 交互设计、信息图、信息可视化、数据可视化技术资源汇总——设计师的领域,设计师说了算

    本文整理了设计师常逛的网站,这些资料信息网站包括交互设计.信息图.信息可视化,在线制图.数据可视化,本文大致的内容包括: <灵感--可以参看如下网站来寻找灵感网站汇总>. <信息图工 ...

  9. 什么是数字孪生?跟数据可视化的关系又是什么?

    大数据产业创新服务媒体 --聚焦数据 · 改变商业 2019年,"数字孪生"热度不断攀升,备受行业内外关注.各大峰会论坛将其作为热议主题,全球最具权威的IT研究与顾问咨询机构Gar ...

最新文章

  1. node.js 多个异步过程判断执行是否完成
  2. vim 自定义命令 自定义快捷键(转)
  3. Magento 获取有效属性 Display available options for attributes of Configurable
  4. blade php代码,Laravel 5框架学习之Blade 简介
  5. RocketMQ(十二)消息堆积与消费延迟
  6. 最新快手JS逆向分析
  7. ps分辨率像素英寸和厘米的区别_南南带你免费学习超级强大的做图软件-PS(第一章:第二节)...
  8. 为什么volatile能保证有序性不能保证原子性
  9. mysql安装sql文件怎么打开_sql文件用什么打开?如何打开sql文件?
  10. python水仙花数_python求解水仙花数的方法
  11. 新路由3 Newifi3 D2 Lede固件
  12. gsp认证计算机系统检查内容,版GSP认证之附录计算机系统检查项目PPT课件.ppt
  13. RQNOJ 169 最小乘车费用
  14. 微信公众号采集之免费采集公众号爆文工具
  15. Docker升级Wekan
  16. 约瑟夫 java_约瑟夫问题 java 实现详解
  17. vue设置必填项和判断必填项是否填入的弹窗提示
  18. 反向传播公式推导,BP神经网络(Back Propagation)/误差逆传播算法推导
  19. Codeforces 918D - MADMAX
  20. 智能快递柜解决方案及整套源代码

热门文章

  1. 【开发工具】 什么是Office 今天让你认识它
  2. 均值滤波器的原理及实现
  3. 二分法、三分法的详解
  4. 您的输出设备不支持HDCP
  5. python爬虫获取vpn代理
  6. String.hashCode() 31?
  7. 医院临床路径管理系统源码 医院管理系统源码
  8. 大公司,还是小公司?
  9. 今日早报 每天群里发的精选12条新闻简报 7月8日
  10. Office Visio 2016安装