Windows7
Anaconda3
pyecharts
pandas
numpy
在Jupyter notebook中利用numpy、pandas、pyecharts进行数据的3D可视化,通过数据分析完成一份基于Python的郑州市二手房数据分析报告。
数据下载:https://download.csdn.net/download/qq_35809147/11176627
import numpy as np
import pandas as pd
from pyecharts import online
online()
data = pd.read_excel(u'C://Users/liulei/Desktop/正常值数据.xlsx')
data.head()
data.loc[:,['UnitPrice', 'TotalPrice', 'Conarea']].describe()
from sklearn.preprocessing import LabelEncoder
class_le = LabelEncoder()
data['IsLift_num'] = class_le.fit_transform(data['IsLift'])
data.IsLift_num[:5]
data['PropertyNature_num']= class_le.fit_transform(data.PropertyNature.values)
data['PropertyNature_num'][:5]
lift_proerty_price = []
for i in range(data.__len__()):
one_info = []
one_info.append(data.loc[i]['PropertyNature_num'])
one_info.append(data.loc[i]['IsLift_num'])
one_info.append(data.loc[i]['UnitPrice'])
lift_proerty_price.append(one_info)
from pyecharts import Bar3D
bar3d = Bar3D("PropertyNature/IsLift/UnitPrice", "PropertyNature、IsLift、UnitPrice三者之间的关系",width=1200, height=600)
x_axis = data.PropertyNature.unique().tolist()
y_axis = data.IsLift.unique().tolist()
range_color = ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
'#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
bar3d.add("", x_axis, y_axis, [[d[0], d[1], d[2]] for d in lift_proerty_price],
is_visualmap=True, visual_range=[0, 60000],
visual_range_color=range_color, grid3d_width=200,
grid3d_depth=80, is_grid3d_rotate=True, grid3d_shading='lambert')
bar3d
conarea_unit_total_price = []
for i in range(data.__len__()):
one_info = []
one_info.append(data.loc[i]['Conarea'])
one_info.append(data.loc[i]['UnitPrice']/10000)
one_info.append(data.loc[i]['TotalPrice'])
conarea_unit_total_price.append(one_info)
from pyecharts import Line3D
range_color = [
'#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
'#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
line3d = Line3D("Conarea/UnitPrice/TotalPrice", "Conarea、UnitPrice、TotalPrice三者之间的关系",width=1200, height=600)
line3d.add("", conarea_unit_total_price, is_visualmap=True, visual_range_color=range_color,
visual_range=[0, 1000], grid3d_rotate_sensitivity=5, is_grid3d_rotate=True, grid3d_rotate_speed=20)
line3d
from pyecharts import Scatter3D
range_color = [
'#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
'#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
scatter3D = Scatter3D("Conarea/UnitPrice/TotalPrice", "Conarea、UnitPrice、TotalPrice三者之间的关系", width=1200, height=600)
scatter3D.add("", conarea_unit_total_price, is_visualmap=True, visual_range=[0, 1000], visual_range_color=range_color)
scatter3D