修改: PriceSystem/sell_price/zhuge0118A.py
This commit is contained in:
@@ -14,7 +14,7 @@ Created on Fri Sep 22 18:18:15 2017
|
||||
|
||||
import os
|
||||
|
||||
print(os.getcwd())
|
||||
#print(os.getcwd())
|
||||
import random
|
||||
import collections
|
||||
import pymongo
|
||||
@@ -141,10 +141,10 @@ def commonprice(ct, rl, p):
|
||||
if ltt > 0:
|
||||
fields1 = {"lat2": 1, "lng2": 1, "city": 1, "region": 1, "cat": 1, "name": 1}
|
||||
lct = seaweed136.find(query1, fields1)
|
||||
#print('lct=',lct)
|
||||
##print('lct=',lct)
|
||||
lf = pandas.DataFrame(list(lct))
|
||||
|
||||
#print('lf=',lf)
|
||||
##print('lf=',lf)
|
||||
|
||||
# lf=fangjia.find_seaweed(query1, fields1)
|
||||
le = lf
|
||||
@@ -184,7 +184,7 @@ def commonprice(ct, rl, p):
|
||||
return numpy.array([])
|
||||
|
||||
def lianjia(ur):
|
||||
# print(ur)
|
||||
# #print(ur)
|
||||
if 'lianjia' in ur:
|
||||
return 0
|
||||
else:
|
||||
@@ -237,7 +237,9 @@ def commonprice(ct, rl, p):
|
||||
x1 = pandas.Series()
|
||||
for i in bb1:
|
||||
a1 = ds[ds['name'] == i]
|
||||
##print('^^^^^^^^')
|
||||
a2 = a1.sort_values(by='s_date', ascending=False)
|
||||
##print('a2=',a2)
|
||||
x1[i] = a2.iloc[0]['fangjia_price']
|
||||
return x1
|
||||
|
||||
@@ -260,7 +262,7 @@ def commonprice(ct, rl, p):
|
||||
|
||||
# data=pandas.DataFrame(pos)
|
||||
data = fangjia.find_disanganf_price(query)
|
||||
# print(data)
|
||||
# #print(data)
|
||||
if data.shape[0] >= 1:
|
||||
# data=add_block(data)
|
||||
data = add_room(data)
|
||||
@@ -285,14 +287,14 @@ def commonprice(ct, rl, p):
|
||||
def hh(ppp, df):
|
||||
ppp['price'] = None
|
||||
aa = list(df.index)
|
||||
# print('aa=',aa)
|
||||
# #print('aa=',aa)
|
||||
for i in ppp.index:
|
||||
kk = ppp['district_name'][i]
|
||||
# print('kk=',kk)
|
||||
# #print('kk=',kk)
|
||||
if kk in aa:
|
||||
# ppp['price'][i]=df[kk]
|
||||
ppp.loc[i, 'price'] = df[kk]
|
||||
# print('df[kk]',df[kk])
|
||||
# #print('df[kk]',df[kk])
|
||||
return ppp
|
||||
|
||||
@timer
|
||||
@@ -325,10 +327,10 @@ def commonprice(ct, rl, p):
|
||||
# lf=pandas.DataFrame(lct)
|
||||
lf = fangjia.find_seaweed(query1, fields1)
|
||||
|
||||
#print('lf',lf[['estate_type2','lng2', 'lat2']])
|
||||
##print('lf',lf[['estate_type2','lng2', 'lat2']])
|
||||
|
||||
le = lf[lf['estate_type2'] == estype]
|
||||
#print(le['name'])
|
||||
##print(le['name'])
|
||||
|
||||
le.index = le['name']
|
||||
|
||||
@@ -338,10 +340,11 @@ def commonprice(ct, rl, p):
|
||||
|
||||
def sort_manhaten(lr):
|
||||
lr1=lr.values
|
||||
print(lr1)
|
||||
lr2=[]
|
||||
|
||||
for m in range(lr1.shape[0]):
|
||||
#print(m)
|
||||
##print(m)
|
||||
distance=abs(lng-lr1[m][0])+abs(lat-lr1[m][1])
|
||||
lr2.append(distance/100000)
|
||||
|
||||
@@ -354,12 +357,12 @@ def commonprice(ct, rl, p):
|
||||
|
||||
lr1=sort_manhaten(lr)
|
||||
|
||||
dirst1 = list(lr1[:,3])
|
||||
dirst1 = list(lr1[:,2])
|
||||
|
||||
#random.shuffle(dirst1)
|
||||
|
||||
dirst = dirst1[:80]
|
||||
#print('dirst=',dirst)
|
||||
##print('dirst=',dirst)
|
||||
|
||||
dirst_plus = dirst + [p[0]]
|
||||
|
||||
@@ -367,17 +370,17 @@ def commonprice(ct, rl, p):
|
||||
"district_name": {"$in": dirst_plus}}
|
||||
|
||||
ppp = fangjia.dis_feature(query_feature)
|
||||
#print('ox'*10,ppp)
|
||||
##print('ox'*10,ppp)
|
||||
|
||||
# print('小区个数= ',len(dirst))
|
||||
# #print('小区个数= ',len(dirst))
|
||||
df1 = zhoubian_xiaoqu(ct, rl, dirst)
|
||||
#print('df1=',df1,'*'*20)
|
||||
##print('df1=',df1,'*'*20)
|
||||
if df1.shape[0] > 1:
|
||||
df = new_data(df1)
|
||||
#print('df=',df)
|
||||
vv = hh(ppp, df)
|
||||
# print('#'*36)
|
||||
#print('vv=',vv)
|
||||
#print('#'*36)
|
||||
##print('vv=',vv)
|
||||
return vv
|
||||
else:
|
||||
return numpy.array([])
|
||||
@@ -411,14 +414,14 @@ def commonprice(ct, rl, p):
|
||||
# lf=pandas.DataFrame(lct)
|
||||
lf = fangjia.find_seaweed(query1, fields1)
|
||||
|
||||
#print('lf',lf[['estate_type2','lng2', 'lat2']])
|
||||
##print('lf',lf[['estate_type2','lng2', 'lat2']])
|
||||
|
||||
#le = lf[lf['estate_type2'] == estype]
|
||||
le = lf
|
||||
#print('le',le[['estate_type2','lng2', 'lat2']])
|
||||
##print('le',le[['estate_type2','lng2', 'lat2']])
|
||||
|
||||
le.index = le['name']
|
||||
print('EEEEEEEEE')
|
||||
#print('EEEEEEEEE')
|
||||
|
||||
lr = le[['lng2', 'lat2']]
|
||||
|
||||
@@ -428,7 +431,7 @@ def commonprice(ct, rl, p):
|
||||
|
||||
dirst = dirst1[:200]
|
||||
|
||||
# print('dirst=',dirst)
|
||||
# #print('dirst=',dirst)
|
||||
|
||||
dirst_plus = dirst + [p[0]]
|
||||
|
||||
@@ -436,17 +439,17 @@ def commonprice(ct, rl, p):
|
||||
"district_name": {"$in": dirst_plus}}
|
||||
|
||||
ppp = fangjia.dis_feature(query_feature)
|
||||
# print('ox'*10,ppp)
|
||||
# #print('ox'*10,ppp)
|
||||
|
||||
# print('小区个数= ',len(dirst))
|
||||
# #print('小区个数= ',len(dirst))
|
||||
df1 = zhoubian_xiaoqu(ct, rl, dirst)
|
||||
#print('df1=',df1,'*'*20)
|
||||
##print('df1=',df1,'*'*20)
|
||||
if df1.shape[0] > 1:
|
||||
df = new_data(df1)
|
||||
#print('df=',df)
|
||||
##print('df=',df)
|
||||
vv = hh(ppp, df)
|
||||
# print('#'*36)
|
||||
# print('vv=',vv)
|
||||
# #print('#'*36)
|
||||
# #print('vv=',vv)
|
||||
return vv
|
||||
else:
|
||||
return numpy.array([])
|
||||
@@ -455,7 +458,7 @@ def commonprice(ct, rl, p):
|
||||
# 提取要计算小区的特征
|
||||
vk = vv[vv['district_name'] == lk]
|
||||
# 删除要计算小区的空特征
|
||||
# print('vk=',vk)
|
||||
# #print('vk=',vk)
|
||||
if vk.shape[0] > 0:
|
||||
|
||||
vk1 = vk.iloc[0].dropna()
|
||||
@@ -464,7 +467,7 @@ def commonprice(ct, rl, p):
|
||||
|
||||
vk2 = list(set(vk1.index) - {'_id', 'district_name', 'region', 'city'})
|
||||
|
||||
# print('vk2=',vk2)
|
||||
# #print('vk2=',vk2)
|
||||
if len(vk2) > 1:
|
||||
vvo = vv[vv['district_name'] != lk]
|
||||
vk3 = vk2 + ['price']
|
||||
@@ -472,9 +475,9 @@ def commonprice(ct, rl, p):
|
||||
vvo1 = vvo[vk31].dropna()
|
||||
|
||||
x1 = vvo1.drop('price', axis=1)
|
||||
# print('x1=',x1)
|
||||
# #print('x1=',x1)
|
||||
y = vvo1['price']
|
||||
# print('y',y)
|
||||
# #print('y',y)
|
||||
|
||||
if len(x1) > 2:
|
||||
|
||||
@@ -482,7 +485,7 @@ def commonprice(ct, rl, p):
|
||||
clf.fit(x1, y)
|
||||
pp1 = vk[vk31].drop('price', axis=1)
|
||||
result = clf.predict(pp1)
|
||||
# print (result)
|
||||
# #print (result)
|
||||
return int(result[0])
|
||||
else:
|
||||
km = vv['price'].dropna()
|
||||
@@ -526,57 +529,57 @@ def commonprice(ct, rl, p):
|
||||
else:
|
||||
# t1=time.time()
|
||||
|
||||
#print("location['lng2'][0]",location['lng2'].iloc[0])
|
||||
##print("location['lng2'][0]",location['lng2'].iloc[0])
|
||||
|
||||
dd = neighbor(location['lng2'].iloc[0], location['lat2'].iloc[0], 5, ct, rl, p)
|
||||
# print(time.time()-t1,'t1'*10)
|
||||
# #print(time.time()-t1,'t1'*10)
|
||||
#print('dd=',dd,'dd'*20)
|
||||
if dd.shape[0] >= factor:
|
||||
# print('$'*50)
|
||||
# #print('$'*50)
|
||||
# dd1=neighbor(location['lng2'][0],location['lat2'][0],5)
|
||||
# print('dd',dd)
|
||||
# #print('dd',dd)
|
||||
# svr_time=time.time()
|
||||
other = svr(dd, lk)
|
||||
# print(time.time()-svr_time,'svr'*10)
|
||||
print('other= ', other, '9' * 20)
|
||||
# #print(time.time()-svr_time,'svr'*10)
|
||||
#print('other= ', other, '9' * 20)
|
||||
return other, dd.shape[0]
|
||||
else:
|
||||
# t2=time.time()
|
||||
dd1 = neighbor(location['lng2'].iloc[0], location['lat2'].iloc[0], 10, ct, rl, p)
|
||||
# print(time.time()-t2,'t2'*10)
|
||||
# print('dd1=',dd1)
|
||||
# #print(time.time()-t2,'t2'*10)
|
||||
# #print('dd1=',dd1)
|
||||
if dd1.shape[0] >= factor:
|
||||
# print('$'*50)
|
||||
# #print('$'*50)
|
||||
|
||||
# svr_time=time.time()
|
||||
other1 = svr(dd1, lk)
|
||||
# print(time.time()-svr_time,'svr'*10)
|
||||
# print('other1=',other1)
|
||||
# #print(time.time()-svr_time,'svr'*10)
|
||||
# #print('other1=',other1)
|
||||
return other1, dd1.shape[0]
|
||||
else:
|
||||
# t3=time.time()
|
||||
dd2 = neighbor(location['lng2'].iloc[0], location['lat2'].iloc[0], 50, ct, rl, p)
|
||||
# print(time.time()-t3,'t3'*10)
|
||||
#print('dd2.shape', dd2.shape[0], '@' * 60)
|
||||
# #print(time.time()-t3,'t3'*10)
|
||||
##print('dd2.shape', dd2.shape[0], '@' * 60)
|
||||
if dd2.shape[0] >= factor:
|
||||
#print('$' * 50)
|
||||
##print('$' * 50)
|
||||
#svr_time = time.time()
|
||||
other1 = svr(dd2, lk)
|
||||
#print(time.time() - svr_time, 'e' * 10)
|
||||
# print('other1=',other1)
|
||||
##print(time.time() - svr_time, 'e' * 10)
|
||||
# #print('other1=',other1)
|
||||
return other1, dd2.shape[0]
|
||||
|
||||
else:
|
||||
|
||||
dd6 = neighbor_km(location['lng2'].iloc[0], location['lat2'].iloc[0], 30, ct, rl, p)
|
||||
# print('dd2=',dd2,'@'*60)
|
||||
# #print('dd2=',dd2,'@'*60)
|
||||
if dd6.shape[0] >= 20:
|
||||
# svr_time=time.time()
|
||||
other1 = svr(dd6, lk)
|
||||
|
||||
#print('#'*20)
|
||||
# print(time.time()-svr_time,'svr'*10)
|
||||
# print('other1=',other1)
|
||||
##print('#'*20)
|
||||
# #print(time.time()-svr_time,'svr'*10)
|
||||
# #print('other1=',other1)
|
||||
return other1, dd6.shape[0]
|
||||
else:
|
||||
return '没有周围小区数据', 0
|
||||
@@ -637,28 +640,28 @@ def commonprice(ct, rl, p):
|
||||
# estype=p[2]
|
||||
alias = p[1]
|
||||
|
||||
# print('alias=',alias)
|
||||
# #print('alias=',alias)
|
||||
|
||||
def filt(x):
|
||||
|
||||
return type(x) == str and len(x) > 1
|
||||
|
||||
bb = list(filter(filt, alias))
|
||||
# print('bb=',bb)
|
||||
# #print('bb=',bb)
|
||||
bb.extend([lw])
|
||||
# lk1=list(set(lk))
|
||||
|
||||
# print('本小区名=',lw)
|
||||
# #print('本小区名=',lw)
|
||||
|
||||
# print('type(lw)=',type(bb))
|
||||
# #print('type(lw)=',type(bb))
|
||||
|
||||
# print('小区名列表=',bb)
|
||||
# #print('小区名列表=',bb)
|
||||
|
||||
cc1 = some_district_information(ct, rl, bb)
|
||||
|
||||
cc1 = add_room(cc1)
|
||||
|
||||
print('cc1本小区数据条数=', cc1.shape[0])
|
||||
#print('cc1本小区数据条数=', cc1.shape[0])
|
||||
|
||||
if cc1.shape[0] > 2:
|
||||
|
||||
@@ -670,7 +673,7 @@ def commonprice(ct, rl, p):
|
||||
|
||||
lkk = lw.strip('别墅')
|
||||
cc = region_district_list_name(ct, rl, lkk)
|
||||
# print('cc=',cc)
|
||||
# #print('cc=',cc)
|
||||
if cc.shape[0] > 1:
|
||||
|
||||
cc1 = list(cc['alias'].dropna())
|
||||
@@ -692,7 +695,7 @@ def commonprice(ct, rl, p):
|
||||
@timer
|
||||
def consider_villa(ct, rl, p):
|
||||
|
||||
# print('villa p=',p)
|
||||
# #print('villa p=',p)
|
||||
|
||||
estype = p[2]
|
||||
df = strip_villa(ct, rl, p)
|
||||
@@ -725,7 +728,7 @@ def commonprice(ct, rl, p):
|
||||
# dd=dd.dropna()
|
||||
d1 = dd[dd['area'] > 150]
|
||||
|
||||
# print(dd)
|
||||
# #print(dd)
|
||||
|
||||
villa_label = ["独栋", "联排", "叠加", "双拼",
|
||||
"花园面积", "泳池", "别墅", "带花园"]
|
||||
@@ -771,7 +774,7 @@ def commonprice(ct, rl, p):
|
||||
pdd = data1[i].dropna()
|
||||
# ser[i]=k_means(pdd)
|
||||
ser[i] = list(pdd)[-1]
|
||||
# print('采用抓取的第三方均价')
|
||||
# #print('采用抓取的第三方均价')
|
||||
return ser
|
||||
|
||||
def sfjj(ll_zz, aa_zz, dddf):
|
||||
@@ -824,7 +827,7 @@ def commonprice(ct, rl, p):
|
||||
|
||||
bb = []
|
||||
for i in junjia_lzf.index:
|
||||
# print(junjia_lzf)
|
||||
# #print(junjia_lzf)
|
||||
someprice = junjia_lzf[i]
|
||||
|
||||
def compare15(b):
|
||||
@@ -834,35 +837,35 @@ def commonprice(ct, rl, p):
|
||||
return 0
|
||||
|
||||
countmap = list(map(compare15, junjia_anst))
|
||||
#print('countmap=',countmap)
|
||||
##print('countmap=',countmap)
|
||||
countmap1 = pandas.Series(countmap)
|
||||
countmap2 = countmap1[countmap1 > 0]
|
||||
# print('countmap2=',countmap2)
|
||||
# #print('countmap2=',countmap2)
|
||||
|
||||
numb = len(countmap2)
|
||||
# print('len(countmap2)=',len(countmap2))
|
||||
# #print('len(countmap2)=',len(countmap2))
|
||||
if numb > ctr:
|
||||
bb.append([someprice, numb])
|
||||
#print('bb=',bb)
|
||||
##print('bb=',bb)
|
||||
return bb
|
||||
|
||||
def middle_operate(junjia_lzf, junjia_anst):
|
||||
|
||||
# print('%%%',ppd3['total_price'])
|
||||
# #print('%%%',ppd3['total_price'])
|
||||
|
||||
# print('junjia_lzf=',junjia_lzf)
|
||||
# print('junjia_anst=',junjia_anst)
|
||||
# #print('junjia_lzf=',junjia_lzf)
|
||||
# #print('junjia_anst=',junjia_anst)
|
||||
|
||||
def mid_out_1(junjia_lzf,per):
|
||||
|
||||
if len(junjia_lzf) > 1:
|
||||
# print('aa1',aa)
|
||||
# #print('aa1',aa)
|
||||
bb = group(junjia_lzf, junjia_lzf, 1,per)
|
||||
# print('bb=',bb)
|
||||
# #print('bb=',bb)
|
||||
if len(bb) > 0:
|
||||
bb1 = pandas.DataFrame(bb, columns=['price', 'count'])
|
||||
bb2 = bb1.sort_values(by='count', ascending=False)
|
||||
#print(bb2)
|
||||
##print(bb2)
|
||||
return bb2.iloc[0]['price']
|
||||
else:
|
||||
return None
|
||||
@@ -874,11 +877,11 @@ def commonprice(ct, rl, p):
|
||||
if len(junjia_lzf) > 0 and len(junjia_anst) > 0:
|
||||
|
||||
bb = group(junjia_lzf, junjia_anst, 0,per)
|
||||
# print('bb1=',bb)
|
||||
# #print('bb1=',bb)
|
||||
if len(bb) > 0:
|
||||
bb1 = pandas.DataFrame(bb, columns=['price', 'count'])
|
||||
bb2 = bb1.sort_values(by='count', ascending=False)
|
||||
# print(bb2)
|
||||
# #print(bb2)
|
||||
return bb2.iloc[0]['price']
|
||||
else:
|
||||
return None
|
||||
@@ -887,18 +890,18 @@ def commonprice(ct, rl, p):
|
||||
|
||||
#a11 = mid_out_1(junjia_lzf,8)
|
||||
|
||||
#print('a11=',a11)
|
||||
##print('a11=',a11)
|
||||
#a22 = mid_out_2(junjia_lzf, junjia_anst,8)
|
||||
#print('a22=',a22)
|
||||
##print('a22=',a22)
|
||||
#a33 = mid_out_1(junjia_anst,8)
|
||||
a44 = mid_out_1(junjia_lzf,16)
|
||||
a55 = mid_out_2(junjia_lzf, junjia_anst,16)
|
||||
a66 = mid_out_1(junjia_anst,16)
|
||||
#print('a33=',a33)
|
||||
##print('a33=',a33)
|
||||
#aa1_6 = pandas.Series([a11, a22, a33,a44,a55,a66]).dropna()
|
||||
aa1_6 = pandas.Series([ a44,a55,a66]).dropna()
|
||||
|
||||
#print('aa1_6=',aa1_6)
|
||||
##print('aa1_6=',aa1_6)
|
||||
if len(aa1_6) > 0:
|
||||
return aa1_6.iloc[0]
|
||||
else:
|
||||
@@ -969,16 +972,16 @@ def commonprice(ct, rl, p):
|
||||
lk = p[0]
|
||||
location = take_location(ct, rl, p)
|
||||
|
||||
#print('location',location)
|
||||
##print('location',location)
|
||||
|
||||
# ttp=time.time()
|
||||
|
||||
neighb = no_source_price(ct, rl, location, p)
|
||||
|
||||
# print(time.time()-ttp,'m'*20)
|
||||
# #print(time.time()-ttp,'m'*20)
|
||||
|
||||
junjia = dsfjujia(ct, rl, lk)
|
||||
#print('junjia=',junjia)
|
||||
##print('junjia=',junjia)
|
||||
|
||||
'''
|
||||
dglg=dsplg(junjia,neighb,2)
|
||||
@@ -987,20 +990,20 @@ def commonprice(ct, rl, p):
|
||||
dglg = dglg_out1(junjia, neighb[0])
|
||||
# dggg=dglg_out1(junjia,neighb[0])
|
||||
|
||||
# print('dglg=',dglg)
|
||||
# print('dggg=',dggg)
|
||||
# #print('dglg=',dglg)
|
||||
# #print('dggg=',dggg)
|
||||
|
||||
# tt=time.time()
|
||||
data = consider_villa(ct, rl, p)
|
||||
# print(time.time()-tt,'<>'*26)
|
||||
# #print(time.time()-tt,'<>'*26)
|
||||
#######################################################
|
||||
|
||||
if data.shape[0] > 3:
|
||||
|
||||
paa = add_block(data)
|
||||
ppd = paa[['total_price', 'area', 'region', 'district_name', 'url', 'block', 'p_date']]
|
||||
# print('ppd##############')
|
||||
# print('ppd=',ppd)
|
||||
# #print('ppd##############')
|
||||
# #print('ppd=',ppd)
|
||||
ppd = ppd.fillna(method='ffill')
|
||||
|
||||
ppd1 = ppd.dropna()
|
||||
@@ -1008,7 +1011,7 @@ def commonprice(ct, rl, p):
|
||||
# t3=time.time()
|
||||
|
||||
ppd1['total_price'] = ppd1['total_price'] / ppd1['area']
|
||||
# print('ppd1time',time.time()-t3,'o'*36)
|
||||
# #print('ppd1time',time.time()-t3,'o'*36)
|
||||
|
||||
# ppd1.loc['total_price']=ppd1['total_price']/ppd1['area']
|
||||
|
||||
@@ -1032,7 +1035,7 @@ def commonprice(ct, rl, p):
|
||||
|
||||
######################################
|
||||
ldf = label(ppd3, lianjia)
|
||||
# print('ldf=',ldf)
|
||||
# #print('ldf=',ldf)
|
||||
|
||||
ldf1 = label(ppd3, zhuge)
|
||||
|
||||
@@ -1043,47 +1046,47 @@ def commonprice(ct, rl, p):
|
||||
|
||||
ldf5 = label(ppd3, wkzf)
|
||||
l_and_z = ldf | ldf1
|
||||
# print(l_and_z)
|
||||
# print('l_and_z=',l_and_z)
|
||||
# #print(l_and_z)
|
||||
# #print('l_and_z=',l_and_z)
|
||||
allf = l_and_z | ldf3 | ldf4 | ldf5 | ldf2
|
||||
# print('l_and_z_and_i=',l_and_z_and_i)
|
||||
# #print('l_and_z_and_i=',l_and_z_and_i)
|
||||
# mm=0
|
||||
length = len(l_and_z)
|
||||
length1 = len(allf)
|
||||
|
||||
if dglg != None:
|
||||
|
||||
# print('junjia.shape',len(junjia))
|
||||
# #print('junjia.shape',len(junjia))
|
||||
sample_size = len(junjia)
|
||||
return dglg, float('%.2f' % credit['0.85']), value_type['第三方'], sample_size
|
||||
|
||||
elif length > 3:
|
||||
# print('ldf=',l_and_z_and_i)
|
||||
# #print('ldf=',l_and_z_and_i)
|
||||
pppk = ppd3.loc[l_and_z, :]
|
||||
|
||||
ppp = pppk[['total_price', 'p_date']]
|
||||
# print(ppp)
|
||||
# #print(ppp)
|
||||
ppp1 = ppp.sort_values(['p_date'], ascending=False)
|
||||
|
||||
gdf = ppp1['total_price'][:36].dropna()
|
||||
# print('链家和诸葛找房合并后的数据集=',gdf)
|
||||
# #print('链家和诸葛找房合并后的数据集=',gdf)
|
||||
sample_size = len(gdf)
|
||||
gm = k_means_clus(gdf, 2)
|
||||
#print('链猪= ', gm)
|
||||
##print('链猪= ', gm)
|
||||
return int(gm), float('%.2f' % credit['0.8']), value_type['自身样本'], sample_size # 优质样本
|
||||
|
||||
|
||||
elif data.shape[0] > 0:
|
||||
|
||||
#print('诸葛找房算法')
|
||||
#print('neighb',neighb)
|
||||
##print('诸葛找房算法')
|
||||
##print('neighb',neighb)
|
||||
# from zhuge import zhuge_consist
|
||||
data['avg'] = data['total_price'] / data['area']
|
||||
|
||||
def guolv_data11(data, neighb):
|
||||
if type(neighb) is not str:
|
||||
|
||||
#print('周边价格=', neighb)
|
||||
##print('周边价格=', neighb)
|
||||
ddd11 = data[data['avg'] > 0.5 * neighb]
|
||||
return ddd11
|
||||
else:
|
||||
@@ -1091,27 +1094,27 @@ def commonprice(ct, rl, p):
|
||||
|
||||
ddd11 = guolv_data11(data, neighb[0])
|
||||
|
||||
# print('ddd11=',ddd11)
|
||||
# #print('ddd11=',ddd11)
|
||||
|
||||
if ddd11.shape[0] > 2:
|
||||
|
||||
# s = zhuge_consist.url_lable(ddd11)
|
||||
# s1 = zhuge_consist.drop_rubbish(s)
|
||||
# print('s1=',s1)
|
||||
# #print('s1=',s1)
|
||||
# s2 = set(s1)
|
||||
# print('s2=',s2)
|
||||
# #print('s2=',s2)
|
||||
if ddd11.shape[0] > 3:
|
||||
|
||||
from zhuge import zhuge_consist
|
||||
|
||||
s = zhuge_consist.zhuge_out(ddd11, 3, 1)
|
||||
|
||||
# print('s=',s)
|
||||
# #print('s=',s)
|
||||
|
||||
def compelex(ddd11, s, neighb, junjia):
|
||||
#cc1 = ddd11['avg'].dropna()
|
||||
|
||||
# print('cc1=',cc1)
|
||||
# #print('cc1=',cc1)
|
||||
|
||||
kmzhuge = zhuge_consist.zhuge_out(ddd11, 3, 0)
|
||||
junjia['zhuge_logic'] = s
|
||||
@@ -1120,37 +1123,37 @@ def commonprice(ct, rl, p):
|
||||
|
||||
if type(neighb) != str and (neighb) != None:
|
||||
junjia['neighb'] = neighb
|
||||
# print('junjia',junjia)
|
||||
# #print('junjia',junjia)
|
||||
|
||||
junjia_front = junjia[['zhuge_logic', 'kmzg']]
|
||||
|
||||
def drop_ganji(junjia):
|
||||
a = {'ganji_esf_price', 'anjuke_esf_price'}
|
||||
# print('a=',a)
|
||||
# #print('a=',a)
|
||||
b = set(list(junjia.index))
|
||||
# print('b=',b)
|
||||
# #print('b=',b)
|
||||
c = a & b
|
||||
|
||||
# print('c=',c)
|
||||
# #print('c=',c)
|
||||
if len(c) == 2:
|
||||
# print('o'*100)
|
||||
# #print('o'*100)
|
||||
return junjia.drop('ganji_esf_price')
|
||||
else:
|
||||
return junjia
|
||||
|
||||
junjia1 = drop_ganji(junjia)
|
||||
|
||||
#print('ddd11',ddd11)
|
||||
##print('ddd11',ddd11)
|
||||
|
||||
#print('junjia_ganji=',junjia1,'$'*100)
|
||||
##print('junjia_ganji=',junjia1,'$'*100)
|
||||
cc = group(junjia_front, junjia1, 1,16)
|
||||
# junjia_km=k_means(junjia)
|
||||
# print('cc=',cc)
|
||||
# #print('cc=',cc)
|
||||
############
|
||||
if len(cc) > 0:
|
||||
cc1 = pandas.DataFrame(cc, columns=['price', 'count'])
|
||||
cc2 = cc1.sort_values(by='count', ascending=False)
|
||||
# print(bb2)
|
||||
# #print(bb2)
|
||||
sample_size = ddd11.shape[0]
|
||||
return cc2.iloc[0]['price'] * 1.0, float('%.2f' % credit['0.7']), value_type[
|
||||
'第三方'], sample_size
|
||||
@@ -1166,7 +1169,7 @@ def commonprice(ct, rl, p):
|
||||
|
||||
|
||||
else:
|
||||
print('*' * 20, '采用周边算法')
|
||||
#print('*' * 20, '采用周边算法')
|
||||
if ddd11.shape[0] > 3:
|
||||
cc1 = ddd11['avg'].dropna()
|
||||
kmzhuge = k_means_clus(cc1, 2)
|
||||
@@ -1176,7 +1179,7 @@ def commonprice(ct, rl, p):
|
||||
return neighb[0], float('%.2f' % credit['0.5']), value_type['周边楼盘'], neighb[1]
|
||||
|
||||
elif dglg != None:
|
||||
print('优质第三方均价2 = ', dglg)
|
||||
#print('优质第三方均价2 = ', dglg)
|
||||
sample_size = len(junjia)
|
||||
return dglg, float('%.2f' % credit['0.8']), value_type['第三方'], sample_size # '优质样本'
|
||||
|
||||
@@ -1184,7 +1187,7 @@ def commonprice(ct, rl, p):
|
||||
return neighb[0], float('%.2f' % credit['0.5']), value_type['周边楼盘'], neighb[1]
|
||||
|
||||
elif dglg != None:
|
||||
print('优质第三方均价3 = ', dglg)
|
||||
#print('优质第三方均价3 = ', dglg)
|
||||
sample_size = len(junjia)
|
||||
return dglg, float('%.2f' % credit['0.8']), value_type['第三方'] # '优质样本'
|
||||
|
||||
@@ -1194,13 +1197,13 @@ def commonprice(ct, rl, p):
|
||||
|
||||
|
||||
elif dglg != None:
|
||||
print('优质第三方均价4 = ', dglg)
|
||||
#print('优质第三方均价4 = ', dglg)
|
||||
return dglg, float('%.2f' % credit['0.8']), value_type['第三方'], len(junjia) # '优质样本'
|
||||
|
||||
else:
|
||||
|
||||
# print('*'*100)
|
||||
# print(neighb)
|
||||
# #print('*'*100)
|
||||
# #print(neighb)
|
||||
return neighb[0], float('%.2f' % credit['0.5']), value_type['周边楼盘'], neighb[1]
|
||||
|
||||
|
||||
@@ -1244,7 +1247,7 @@ def region_district_list_lk(ct, rl, lk):
|
||||
|
||||
def last_sunday(weekend):
|
||||
|
||||
#print('weekend_up',weekend)
|
||||
##print('weekend_up',weekend)
|
||||
# import datetime
|
||||
|
||||
last_sunday = weekend - datetime.timedelta(days=7)
|
||||
@@ -1252,7 +1255,7 @@ def last_sunday(weekend):
|
||||
#weekend1 = datetime.datetime.strptime(d1, '%Y%m%d')
|
||||
#weekend = weekend1 + datetime.timedelta(hours=-8)
|
||||
|
||||
#print('weekend',last_sunday)
|
||||
##print('weekend',last_sunday)
|
||||
return last_sunday
|
||||
|
||||
|
||||
@@ -1260,7 +1263,7 @@ def last_sunday(weekend):
|
||||
|
||||
def make_up_price(ct, rl, lk, weekend):
|
||||
|
||||
print('lg=',ct,rl,lk)
|
||||
#print('lg=',ct,rl,lk)
|
||||
# last_sunday=last_sunday(weekend)
|
||||
# save_lg=client136.fangjia.district_stat
|
||||
if lk != None:
|
||||
@@ -1281,8 +1284,8 @@ def make_up_price(ct, rl, lk, weekend):
|
||||
# pos=pos[pos['week1']>cc-5]
|
||||
# pos=pos.sort_values(by='week1',ascending=False)
|
||||
|
||||
# print('5'*10)
|
||||
# print(pos)
|
||||
# #print('5'*10)
|
||||
# #print(pos)
|
||||
|
||||
if pos.shape[0] > 0:
|
||||
# pp1"""
|
||||
@@ -1310,8 +1313,8 @@ def make_up_price(ct, rl, lk, weekend):
|
||||
# pos=pos[pos['week1']>cc-5]
|
||||
# pos=pos.sort_values(by='week1',ascending=False)
|
||||
|
||||
# print('5'*10)
|
||||
# print(pos)
|
||||
# #print('5'*10)
|
||||
# #print(pos)
|
||||
|
||||
if pos.shape[0] > 0:
|
||||
# pp1
|
||||
@@ -1378,16 +1381,16 @@ def out_put_price(ct, rl, lk, weekend):
|
||||
lf = add_alias(lf)
|
||||
p = ghhh(lf[['name', 'alias', 'estate_type2']])[0]
|
||||
|
||||
#print('p=', p)
|
||||
##print('p=', p)
|
||||
|
||||
mm = commonprice(ct, rl, p)
|
||||
#print('mm=',mm)
|
||||
##print('mm=',mm)
|
||||
c_date = datetime.datetime.utcnow()
|
||||
m_date = datetime.datetime.utcnow()
|
||||
estate_type = lf['estate_type2'].iloc[0]
|
||||
|
||||
|
||||
#print('estate_type',estate_type)
|
||||
##print('estate_type',estate_type)
|
||||
|
||||
|
||||
estate_type,cmd_estate_type = out_estate_type(estate_type)
|
||||
@@ -1395,18 +1398,18 @@ def out_put_price(ct, rl, lk, weekend):
|
||||
|
||||
if type(mm[0]) != str:
|
||||
|
||||
print(ct, rl, lk, mm, '$' * 20)
|
||||
# print(lf['estate_type2'].iloc[0],'*'*10)
|
||||
#print(ct, rl, lk, mm, '$' * 20)
|
||||
# #print(lf['estate_type2'].iloc[0],'*'*10)
|
||||
|
||||
|
||||
# last_sunday=last_sunday()
|
||||
# t1=time.time()
|
||||
last_sunday_price = make_up_price(ct, rl, lk, weekend)
|
||||
|
||||
# print(time.time()-t1,'*'*20)
|
||||
# #print(time.time()-t1,'*'*20)
|
||||
|
||||
# print('last_sunday_price',last_sunday_price)
|
||||
# print('mm[0]',mm[0])
|
||||
# #print('last_sunday_price',last_sunday_price)
|
||||
# #print('mm[0]',mm[0])
|
||||
|
||||
def make_up():
|
||||
if type(last_sunday_price) != str and last_sunday_price != None and mm[0] != None and type(mm[0]) != str:
|
||||
@@ -1418,8 +1421,8 @@ def out_put_price(ct, rl, lk, weekend):
|
||||
|
||||
make_up = int(make_up())
|
||||
|
||||
#print('make_up',make_up,'*'*20)
|
||||
#print('credic',mm[1])
|
||||
##print('make_up',make_up,'*'*20)
|
||||
##print('credic',mm[1])
|
||||
|
||||
try:
|
||||
|
||||
|
||||
+3
-3
@@ -38,11 +38,11 @@ lk = '会展世界城三期'
|
||||
ct='洛阳'
|
||||
rl='涧西'
|
||||
lk='奥阳康城'上海浦东龚家阁龚家花园绍兴越城辕门新村
|
||||
南区亨纳斯花园杨浦上海嘉定浏翔花苑北京 昌平 回龙观三期
|
||||
南区亨纳斯花园杨浦上海嘉定浏翔花苑北京 昌平 回龙观三期'东华苑
|
||||
"""
|
||||
ct='上海'
|
||||
rl='杨浦'
|
||||
lk='亨纳斯花园'
|
||||
rl='闵行'
|
||||
lk='上海康城'
|
||||
|
||||
#成都双流长滩一号 上海 奉贤 朝阳新村##上海 奉贤 棕榈滩别墅深圳龙岗丽皇阁
|
||||
#洛阳涧西奥阳康城
|
||||
|
||||
Reference in New Issue
Block a user