优化更新
This commit is contained in:
@@ -19,7 +19,6 @@ import numpy as np
|
||||
|
||||
es = ElasticSearchClient(host='192.168.0.206')
|
||||
seaweed_df = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||
one_year_time = dateutils.format_date(dateutils.add_months(dateutils.datetime.datetime.now(), days=-365))
|
||||
office_rent_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'office_rent_stat')
|
||||
|
||||
# 计算有样本写字楼的基准价 1. 取近一年,最近100个样本的中位值
|
||||
@@ -41,7 +40,10 @@ def calc(city, year_month):
|
||||
year_month = int(dateutils.format_date(date, '%Y%m'))
|
||||
|
||||
sample = es.scan_by_sql_to_data_frame(sql)
|
||||
office = pd.DataFrame(list(seaweed_df.find({'cat': 'office', 'status': 0}).batch_size(10000)))
|
||||
query = {'cat': 'office', 'status': 0}
|
||||
if pd.notna(city):
|
||||
query['city'] = city
|
||||
office = pd.DataFrame(list(seaweed_df.find(query).batch_size(10000)))
|
||||
office = office[['city', 'region', 'name', 'alias', 'estate_type2', 'bed_kind', 'lng', 'lat']]
|
||||
office = office.explode('alias')
|
||||
|
||||
@@ -244,7 +246,7 @@ def calc(city, year_month):
|
||||
'calc_type': 3, 'updated_date': datetime.now()}},
|
||||
upsert=True)
|
||||
actions.append(action)
|
||||
if len(actions) == 5000:
|
||||
if len(actions) == 1000:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
|
||||
@@ -294,10 +296,12 @@ def calc(city, year_month):
|
||||
'calc_type': 4, 'updated_date': datetime.now()}},
|
||||
upsert=True)
|
||||
actions.append(action)
|
||||
if len(actions) == 5000:
|
||||
if len(actions) == 1000:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
|
||||
for year_month in range(202406, 202501):
|
||||
calc('上海', year_month)
|
||||
# for year_month in range(202406, 202501):
|
||||
# print(year_month)
|
||||
# calc('上海', year_month)
|
||||
calc('上海', 202412)
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user