-
Notifications
You must be signed in to change notification settings - Fork 331
R. 房地产数据
xchen2333 edited this page Jul 17, 2018
·
8 revisions
OpenDataTools通过realestate接口,支持对二手房数据的获取,要求版本0.5.3以上。
数据来源:安居客、链家
from opendatatools import realestate
- 获取城市列表
city_list = realestate.get_city_list()
print(city_list)
- 获取城市最新房价信息
df, msg = realestate.get_real_house_price('北京')
df
- 一线城市房价大比拼
import pandas as pd
from pyecharts import Bar
def draw_price(city_list, title):
df_list = []
for city in city_list:
df, msg = realestate.get_real_house_price(city)
if df is not None:
df_list.append(df)
df = pd.concat(df_list)
df = df[df['date'] == '201807']
df.sort_values('price', inplace=True, ascending=True)
axis_x = df['city']
axis_y = df['price']
bar = Bar(title, width=600, height=600)
bar.add("房价", axis_x, axis_y, is_convert=True, is_label_show=True,
bar_category_gap='50%', label_pos='right')
return bar
# 一线城市房价比拼
draw_price(['北京', '上海', '广州', '深圳'], "一线城市房价大比拼")
# 新一线城市房价比拼
draw_price(['成都', '杭州', '重庆', '武汉', '苏州', '西安', '天津', '南京',
'郑州', '长沙', '沈阳', '青岛', '宁波', '东莞', '无锡'],
'新一线城市房价比拼')
- 获取二手房价格数据
df = realestate.get_esf_list_lianjia('北京', max_page_no = 3)
df.head(10)