36 lines
1.7 KiB
Python
36 lines
1.7 KiB
Python
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
import pandas as pd
|
|
from common import configs
|
|
import common
|
|
|
|
# region_rent = common.get_mongodb_collection(configs.SEAWEED_URI, "fangjia_rent", "region_rent")
|
|
# price_rent = dict()
|
|
# for region in common.get_regions("北京"):
|
|
# df = pd.DataFrame(list(region_rent.find({"cat": "region", "region": region}, {"price_rent_ratio": 1})))
|
|
# if len(df) > 0:
|
|
# price_rent[region] = int(df["price_rent_ratio"].mean())
|
|
# plt.rcParams['font.sans-serif'] = ['SimHei']
|
|
# district_rent = common.get_mongodb_collection(configs.SEAWEED_URI, "fangjia_rent", "district_rent")
|
|
# plt.rcParams['savefig.dpi'] = 800
|
|
# plt.rcParams['figure.dpi'] = 800
|
|
# plt.rcParams['figure.figsize'] = (6, 4)
|
|
# for region in common.get_regions("北京"):
|
|
# df = pd.DataFrame(list(district_rent.find({"region": region}, {"price_rent_ratio": 1})))
|
|
# ratio = np.array(df["price_rent_ratio"])
|
|
# result = pd.value_counts(ratio)
|
|
# result = result.sort_index()
|
|
# fig, ax = plt.subplots()
|
|
# ax.plot(result.index, result.values)
|
|
# if region in price_rent:
|
|
# y = np.arange(int(max(result.values) * 1.2))
|
|
# x = np.zeros(len(y)) + price_rent[region]
|
|
# ax.plot(x, y, label="区域售租比")
|
|
# ax.plot(x * 2, y, '--', label="2倍区域售租比")
|
|
# ax.plot(x * 0.4, y, '-', label="0.4倍区域售租比")
|
|
# ax.set(xlabel='售租比', ylabel='小区量', title=region + '区小区售租比分布图')
|
|
# ax.grid()
|
|
# plt.legend()
|
|
# plt.savefig("D:\\建设银行\\租售比\\" + region + "租售比分布分布图.png")
|
|
numbers = np.array([12000, 12000, 14900, 20000])
|
|
print(common.k_means(numbers)) |