This commit is contained in:
2018-03-08 11:46:52 +08:00
parent 00b9a2ef1f
commit cd712cc6f8
2 changed files with 276 additions and 346 deletions
+2 -2
View File
@@ -6,8 +6,8 @@ import sell_price.zhuge0118A as sellPrice
s = time.time() s = time.time()
ct = '上海' ct = '上海'
rl = '闵行' rl = '嘉定'
lk = '上海康城' lk = '莱茵北郡'
weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d") weekend = datetime.datetime.strptime("2018-03-11", "%Y-%m-%d")
sellPrice.out_put_price(ct, rl, lk, weekend) sellPrice.out_put_price(ct, rl, lk, weekend)
+8 -78
View File
@@ -11,23 +11,11 @@ import numpy
import collections import collections
import re import re
from fangjia import timer from fangjia import timer
@timer
def url_lable(dmi1):
company_list=['lianjia','zhuge','5i5j','iwjw','fangdd','centanet', 'cityhouse','baixing','ganji','anjuke','58']
##有Bug
for p in company_list:
for k in dmi1.index:
ff=dmi1['url'][k]
if type(ff)==str:
if p in dmi1['url'][k]:
dmi1.loc[k,'url']=p
return dmi1
def url_to_root(url): def url_to_root(url):
company_list = ['lianjia', 'zhuge', '5i5j', 'iwjw', 'fangdd', 'centanet', 'cityhouse', 'baixing', 'ganji', company_list = ['lianjia', 'zhuge', '5i5j', 'iwjw', 'fangdd', 'centanet', 'cityhouse', 'baixing', 'ganji',
'anjuke', '58'] 'anjuke', '58.com']
for c in company_list: for c in company_list:
if c in url: if c in url:
return c return c
@@ -35,18 +23,16 @@ def url_to_root(url):
return url return url
# @timer @timer
# def url_lable(dmi1): def url_lable(dmi1):
# house_list = dmi1.to_dict('records')
# house_list = dmi1.to_dict('records') for h in house_list:
# for h in house_list: h["url"] = url_to_root(h["url"])
# h["url"] = url_to_root(h["url"]) dmi1 = pandas.DataFrame(house_list)
# dmi1 = pandas.DataFrame(house_list) return dmi1
# return dmi1
def drop_rubbish(dd1): def drop_rubbish(dd1):
for i in dd1.index: for i in dd1.index:
pp = dd1['url'][i] pp = dd1['url'][i]
@@ -64,7 +50,6 @@ def drop_rubbish(dd1):
@timer @timer
def zhuge_out(ddd): def zhuge_out(ddd):
# print('我在诸葛文件内',ddd) # print('我在诸葛文件内',ddd)
def k_means(pp, clus): def k_means(pp, clus):
@@ -123,7 +108,6 @@ def zhuge_out(ddd):
return url_price return url_price
def k_means_ratio(pp, clus): def k_means_ratio(pp, clus):
from sklearn.cluster import KMeans from sklearn.cluster import KMeans
pv = list(pp) pv = list(pp)
@@ -145,7 +129,6 @@ def zhuge_out(ddd):
else: else:
return 1 return 1
def popo(dmi, columns): def popo(dmi, columns):
most = Counter(dmi[columns]).most_common(1) most = Counter(dmi[columns]).most_common(1)
@@ -166,7 +149,6 @@ def zhuge_out(ddd):
# print('dmi2=',dmi2) # print('dmi2=',dmi2)
if (ratio2 < 0.15 and len(dmiy) > 1) or (ratio2 > 1.2 and len(dmiy) > 1): if (ratio2 < 0.15 and len(dmiy) > 1) or (ratio2 > 1.2 and len(dmiy) > 1):
return [round(ww1, 2), round(ww2, 2), round(ww3, 2), round(100, 2), ww4, ww5] return [round(ww1, 2), round(ww2, 2), round(ww3, 2), round(100, 2), ww4, ww5]
# print('area_filter',dd) # print('area_filter',dd)
@@ -175,16 +157,12 @@ def zhuge_out(ddd):
return [round(ww1,2),round(ww2,2),round(ww3,2),round(len(dmiy),2),ww4,ww5] return [round(ww1,2),round(ww2,2),round(ww3,2),round(len(dmiy),2),ww4,ww5]
""" """
def room_define(dd, j): def room_define(dd, j):
pdd = numpy.array([[None, None, None, None, None, None], pdd = numpy.array([[None, None, None, None, None, None],
[None, None, None, None, None, None], [None, None, None, None, None, None],
[None, None, None, None, None, None]]) [None, None, None, None, None, None]])
d4 = dd[dd['room'] == j] d4 = dd[dd['room'] == j]
# print('room=',j,'的样本个数为',d4.shape[0]) # print('room=',j,'的样本个数为',d4.shape[0])
@@ -193,8 +171,6 @@ def zhuge_out(ddd):
most_area = Counter(d4['area']).most_common(1) most_area = Counter(d4['area']).most_common(1)
if most_area[0][1] >= 2: if most_area[0][1] >= 2:
d4area = d4[d4['area'] == most_area[0][0]] d4area = d4[d4['area'] == most_area[0][0]]
@@ -210,14 +186,12 @@ def zhuge_out(ddd):
return (pdd) return (pdd)
def dout(room_pair, dd): def dout(room_pair, dd):
bbb = [] bbb = []
# print('room_pair=',room_pair) # print('room_pair=',room_pair)
# print('dd=',dd) # print('dd=',dd)
for j in room_pair.index: for j in room_pair.index:
kgg = pandas.DataFrame(room_define(dd, j), kgg = pandas.DataFrame(room_define(dd, j),
columns=['total_price', 'area', 'room', 'credit', 'url_list', 'choose_index']) columns=['total_price', 'area', 'room', 'credit', 'url_list', 'choose_index'])
kgg['avg_price'] = kgg['total_price'] / kgg['area'] kgg['avg_price'] = kgg['total_price'] / kgg['area']
@@ -227,12 +201,6 @@ def zhuge_out(ddd):
bbb.append(kgg) bbb.append(kgg)
return bbb return bbb
def dsf_average_price(ct, rl, lk, timd, timm): def dsf_average_price(ct, rl, lk, timd, timm):
client = pymongo.MongoClient('192.168.0.136', 27017) # '192.168.0.65',27777 client = pymongo.MongoClient('192.168.0.136', 27017) # '192.168.0.65',27777
@@ -253,7 +221,6 @@ def zhuge_out(ddd):
del pos del pos
return data return data
dsf_name_list = {'soufang_new_price', 'soufang_esf_price', dsf_name_list = {'soufang_new_price', 'soufang_esf_price',
'anjuke_new_price', 'anjuke_esf_price', 'anjuke_new_price', 'anjuke_esf_price',
'sina_new_price', 'sina_esf_price', 'sina_new_price', 'sina_esf_price',
@@ -264,11 +231,6 @@ def zhuge_out(ddd):
'fanggugu_esf_price', 'yungujia_esf_price' 'fanggugu_esf_price', 'yungujia_esf_price'
} }
company_list = ['lianjia', 'zhuge', '5i5j', 'iwjw', 'fangdd', 'centanet', company_list = ['lianjia', 'zhuge', '5i5j', 'iwjw', 'fangdd', 'centanet',
'cityhouse', 'baixing', 'ganji', 'anjuke', '58'] 'cityhouse', 'baixing', 'ganji', 'anjuke', '58']
@@ -285,7 +247,6 @@ def zhuge_out(ddd):
company_pandas = pandas.DataFrame(a.T, columns=['name', 'values'], index=company_list) company_pandas = pandas.DataFrame(a.T, columns=['name', 'values'], index=company_list)
name_pair = pandas.Series(company_list, index=company_name) name_pair = pandas.Series(company_list, index=company_name)
def add_floor(ppd): def add_floor(ppd):
if 'floor' not in ppd.columns: if 'floor' not in ppd.columns:
ppd['floor'] = 6 ppd['floor'] = 6
@@ -293,7 +254,6 @@ def zhuge_out(ddd):
# ddd=url_lable(company_list,ddd) # ddd=url_lable(company_list,ddd)
@timer @timer
def opfm(ddo, fm): def opfm(ddo, fm):
@@ -309,10 +269,6 @@ def zhuge_out(ddd):
ddo[fm] = ddo[fm].fillna(2) ddo[fm] = ddo[fm].fillna(2)
return ddo return ddo
@timer @timer
def export_pp(ddd): def export_pp(ddd):
@@ -324,12 +280,9 @@ def zhuge_out(ddd):
if ddo.shape[0] > 1: if ddo.shape[0] > 1:
ddo = opfm(ddo, 'floor') ddo = opfm(ddo, 'floor')
ddo = opfm(ddo, 'room') ddo = opfm(ddo, 'room')
ddo['area'] = (ddo['area'] // 2) * 2 + 1 ddo['area'] = (ddo['area'] // 2) * 2 + 1
# dd1=url_lable(company_list,ddo) # dd1=url_lable(company_list,ddo)
@@ -374,7 +327,6 @@ def zhuge_out(ddd):
else: else:
return pp.mean() return pp.mean()
def out_put_price(opt): def out_put_price(opt):
re = pandas.concat(opt) re = pandas.concat(opt)
@@ -435,25 +387,3 @@ ddd=some_district_information(ct,rl,lk,timd,timm)
df=zhuge_out(ddd) df=zhuge_out(ddd)
""" """