添加楼盘评级算法
This commit is contained in:
@@ -16,7 +16,8 @@ log.info(f"系统当前时间 : {now}")
|
|||||||
|
|
||||||
# 区域维度,统计2个月内样本数据量
|
# 区域维度,统计2个月内样本数据量
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
sql = 'select city,region,p_date,cat,root from seawater where cat = \'sell\' and p_date >='+str(last_day)+' and p_date<'+str(now_day)
|
sql = 'select city,region,p_date,cat,root from seawater where cat = \'sell\' and p_date >=' + str(
|
||||||
|
last_day) + ' and p_date<' + str(now_day)
|
||||||
log.info(f"城市区域维度 sql : {sql}")
|
log.info(f"城市区域维度 sql : {sql}")
|
||||||
df = es206_client.scan_by_sql_to_data_frame(sql)
|
df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||||
|
|
||||||
@@ -53,7 +54,6 @@ log.info(f"房源网站维度-百分比 上月sql : {sql2}")
|
|||||||
df_root1 = es206_client.scan_by_sql_to_data_frame(sql1)
|
df_root1 = es206_client.scan_by_sql_to_data_frame(sql1)
|
||||||
df_root2 = es206_client.scan_by_sql_to_data_frame(sql2)
|
df_root2 = es206_client.scan_by_sql_to_data_frame(sql2)
|
||||||
|
|
||||||
|
|
||||||
df_root_group1 = pd.DataFrame(df_root1.groupby(by=['root'])['_id'].count()).reset_index()
|
df_root_group1 = pd.DataFrame(df_root1.groupby(by=['root'])['_id'].count()).reset_index()
|
||||||
df_root_group2 = pd.DataFrame(df_root2.groupby(by=['root'])['_id'].count()).reset_index()
|
df_root_group2 = pd.DataFrame(df_root2.groupby(by=['root'])['_id'].count()).reset_index()
|
||||||
|
|
||||||
@@ -68,7 +68,8 @@ count_old = 'count_'+strat_time2[0:6]
|
|||||||
|
|
||||||
df_root_merge = df_root_merge.rename(columns={'count_x': count_new, 'count_y': count_old})
|
df_root_merge = df_root_merge.rename(columns={'count_x': count_new, 'count_y': count_old})
|
||||||
|
|
||||||
df_root_res = df_root_merge.drop(df_root_merge[~((df_root_merge[count_new]<df_root_merge[count_old]) & ((df_root_merge[count_old]-df_root_merge[count_new])/df_root_merge[count_old]>0.3))].index)
|
df_root_res = df_root_merge.drop(df_root_merge[~((df_root_merge[count_new] < df_root_merge[count_old]) & (
|
||||||
|
(df_root_merge[count_old] - df_root_merge[count_new]) / df_root_merge[count_old] > 0.3))].index)
|
||||||
|
|
||||||
if df_root_res.empty == False:
|
if df_root_res.empty == False:
|
||||||
if text == '':
|
if text == '':
|
||||||
@@ -83,7 +84,8 @@ log.info(f"房源网站维度-数量 city_list : {city_list}")
|
|||||||
|
|
||||||
df_root_city_group1 = pd.DataFrame(df_root1.groupby(by=['root', 'city'])['_id'].count()).reset_index()
|
df_root_city_group1 = pd.DataFrame(df_root1.groupby(by=['root', 'city'])['_id'].count()).reset_index()
|
||||||
df_root_city_group1 = df_root_city_group1.rename(columns={'_id': 'count'})
|
df_root_city_group1 = df_root_city_group1.rename(columns={'_id': 'count'})
|
||||||
df_root_city_res = df_root_city_group1[(df_root_city_group1['city'].isin(city_list)) & (df_root_city_group1['count']<100)].reset_index()
|
df_root_city_res = df_root_city_group1[
|
||||||
|
(df_root_city_group1['city'].isin(city_list)) & (df_root_city_group1['count'] < 100)].reset_index()
|
||||||
|
|
||||||
if df_root_city_res.empty == False:
|
if df_root_city_res.empty == False:
|
||||||
if text == '':
|
if text == '':
|
||||||
@@ -93,6 +95,7 @@ path = "/home/airflow/data/jh/price"
|
|||||||
file_name = f"{now_day}房源样本数量检测.xlsx"
|
file_name = f"{now_day}房源样本数量检测.xlsx"
|
||||||
air_file_name = path + '/' + file_name
|
air_file_name = path + '/' + file_name
|
||||||
|
|
||||||
|
|
||||||
def up_to_nextcloud():
|
def up_to_nextcloud():
|
||||||
"""
|
"""
|
||||||
上传统计信息至nextcloud
|
上传统计信息至nextcloud
|
||||||
@@ -105,21 +108,17 @@ def up_to_nextcloud():
|
|||||||
nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD)
|
nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD)
|
||||||
nxc.upload_file(air_file_name, nextcloud_file_name)
|
nxc.upload_file(air_file_name, nextcloud_file_name)
|
||||||
|
|
||||||
|
|
||||||
if text != '':
|
if text != '':
|
||||||
with pd.ExcelWriter(air_file_name) as writer:
|
with pd.ExcelWriter(air_file_name) as writer:
|
||||||
if df_region_res.empty == False:
|
if df_region_res.empty == False:
|
||||||
df_region_res.to_excel(writer, sheet_name="房源样本数量检测-区域维度", columns=["city", "region", 'count'], index=False)
|
df_region_res.to_excel(writer, sheet_name="房源样本数量检测-区域维度", columns=["city", "region", 'count'], index=False)
|
||||||
if df_root_city_res.empty == False:
|
if df_root_city_res.empty == False:
|
||||||
df_root_city_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本数)", columns=['root','city','count'], index=False)
|
df_root_city_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本数)", columns=['root', 'city', 'count'],
|
||||||
|
index=False)
|
||||||
if df_root_res.empty == False:
|
if df_root_res.empty == False:
|
||||||
df_root_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本减少百分比)", columns=['root',count_old,count_new], index=False)
|
df_root_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本减少百分比)", columns=['root', count_old, count_new],
|
||||||
|
index=False)
|
||||||
up_to_nextcloud()
|
up_to_nextcloud()
|
||||||
token = '1b6d0d782d3c316f2d3b6b18ea5144816170dd392befbf2042a24a01fb84b736'
|
token = '1b6d0d782d3c316f2d3b6b18ea5144816170dd392befbf2042a24a01fb84b736'
|
||||||
dingutils.send_text(text, token)
|
dingutils.send_text(text, token)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ for server_area in server_area_conn.find({'display': {'$ne': '全国'}}, {"displ
|
|||||||
data = pd.DataFrame(
|
data = pd.DataFrame(
|
||||||
district_stat_conn.find({"city": city, "weekend": weekend},
|
district_stat_conn.find({"city": city, "weekend": weekend},
|
||||||
{"_id": 0, "region": 1, "district_name": 1, "avg_price": 1}))
|
{"_id": 0, "region": 1, "district_name": 1, "avg_price": 1}))
|
||||||
if len(data['avg_price'].unique()) < 5:
|
if "avg_price" not in data or len(data['avg_price'].unique()) < 5:
|
||||||
continue
|
continue
|
||||||
data['city'] = city
|
data['city'] = city
|
||||||
logger.info(f"开始计算{city}楼盘评级 weekend:{dateutils.format_date(weekend, '%Y-%m-%d')}")
|
logger.info(f"开始计算{city}楼盘评级 weekend:{dateutils.format_date(weekend, '%Y-%m-%d')}")
|
||||||
|
|||||||
Reference in New Issue
Block a user