优化价格类型

This commit is contained in:
沈健
2025-03-31 14:43:22 +08:00
parent 515351d56b
commit dcce114957
5 changed files with 41 additions and 33 deletions
+18 -14
View File
@@ -76,6 +76,7 @@ def calc(city, year_month):
# 第一步:计算有样本写字楼的基准价
print("有样本数量:" + str(len(merge_df)))
actions = list()
count = 0
for index, item in merge_df.iterrows():
city = item['city']
region = item['region']
@@ -96,9 +97,13 @@ def calc(city, year_month):
actions.append(action)
if len(actions) == 1000:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
if len(actions) > 0:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
# 第二步 取周边3公里内同等级、同类型的最近10个有样本写字楼的基准价的平均值
@@ -155,9 +160,13 @@ def calc(city, year_month):
actions.append(action)
if len(actions) == 1000:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
if len(actions) > 0:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
# 系数计算在Jupyter中
@@ -259,9 +268,13 @@ def calc(city, year_month):
actions.append(action)
if len(actions) == 1000:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
if len(actions) > 0:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
# 第五步
query = {'cat': 'office', 'date': year_month, 'calc_type': {'$in': [1, 2, 3]}}
@@ -331,23 +344,14 @@ def calc(city, year_month):
actions.append(action)
if len(actions) == 1000:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
if len(actions) > 0:
office_sell_stat_conn.bulk_write(actions)
count += len(actions)
print("已计算" + str(count) + "条数据")
actions.clear()
yearmonth = sys.argv[1] if len(sys.argv) > 1 else None
for yearmonth in [
"202406",
"202407",
"202408",
"202409",
"202410",
"202411",
"202412",
"202501"
]:
calc(None, yearmonth)
# # calc("广州", yearmonth)
# # calc("武汉", yearmonth)
# calc("深圳", yearmonth)
calc(None, yearmonth)