租金BUG修复
This commit is contained in:
@@ -35,13 +35,15 @@ def calc(city, year_month):
|
||||
dateutils.add_months(dateutils.parse_date(str(year_month), '%Y%m'), months=-13), '%Y%m')
|
||||
last_month = dateutils.format_date(dateutils.add_months(dateutils.parse_date(str(year_month), '%Y%m'), months=-1), '%Y%m')
|
||||
sql += "and p_date >= '" + last_year_month + "01' "
|
||||
if isinstance(year_month, str):
|
||||
year_month = int(year_month)
|
||||
else:
|
||||
last_year_month = dateutils.format_date(dateutils.add_months(datetime.now(), months=-13), '%Y%m')
|
||||
last_month = dateutils.format_date(dateutils.add_months(datetime.now(), months=-1), '%Y%m')
|
||||
sql += "and p_date >= '" + last_year_month + "01' "
|
||||
date = dateutils.add_months(datetime.today(), months=-1)
|
||||
year_month = int(dateutils.format_date(date, '%Y%m'))
|
||||
print("开始计算年" + year_month + "写字楼基准价")
|
||||
print("开始计算年" + str(year_month) + "写字楼基准价")
|
||||
|
||||
sample = es.scan_by_sql_to_data_frame(sql)
|
||||
query = {'cat': 'office', 'status': 0}
|
||||
@@ -95,15 +97,16 @@ def calc(city, year_month):
|
||||
if len(actions) == 1000:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
if len(actions) > 0:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
|
||||
# 第二步 取周边3公里内同等级、同类型的最近10个有样本写字楼的基准价的平均值
|
||||
office_info = office[['city', 'region', 'name', 'lng', 'lat', 'estate_type2', 'bed_kind']].drop_duplicates(keep='first')
|
||||
combined = pd.concat([office_info, merge_df])
|
||||
diff_df = combined.drop_duplicates(subset=['city', 'region', 'name'], keep=False)
|
||||
actions = list()
|
||||
for index, item in diff_df[(diff_df['estate_type2'].notna()) & (diff_df['bed_kind'].notna())].iterrows():
|
||||
for index, item in diff_df[(diff_df['estate_type2'].notna()) & (diff_df['bed_kind'].notna()) & (diff_df['lng'].notna()) ].iterrows():
|
||||
location = {
|
||||
"type": "Point",
|
||||
"coordinates": [item['lng'] / math.pow(10, 10), item['lat'] / math.pow(10, 10)]
|
||||
@@ -153,8 +156,9 @@ def calc(city, year_month):
|
||||
if len(actions) == 1000:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
if len(actions) > 0:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
|
||||
# 系数计算在Jupyter中
|
||||
bed_kind_dict = {'甲级': 1.111888111888112, '丙级': 0.9143356643356645, '乙级': 1}
|
||||
@@ -256,7 +260,9 @@ def calc(city, year_month):
|
||||
if len(actions) == 1000:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
|
||||
if len(actions) > 0:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
# 第五步
|
||||
query = {'cat': 'office', 'date': year_month, 'calc_type': {'$in': [1, 2, 3]}}
|
||||
if pd.notna(city):
|
||||
@@ -314,8 +320,9 @@ def calc(city, year_month):
|
||||
if len(actions) == 1000:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
if len(actions) > 0:
|
||||
office_rent_stat_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
|
||||
yearmonth = sys.argv[1] if len(sys.argv) > 1 else None
|
||||
|
||||
calc(None, yearmonth)
|
||||
Reference in New Issue
Block a user