租金BUG修复

This commit is contained in:
沈健
2025-03-20 14:51:18 +08:00
parent 7568cefde6
commit 4f9fe0dce9
+5 -1
View File
@@ -276,6 +276,7 @@ def calc(city, year_month):
diff_df = combined.drop_duplicates(subset=['city', 'region', 'name'], keep=False) diff_df = combined.drop_duplicates(subset=['city', 'region', 'name'], keep=False)
actions.clear() actions.clear()
for index, item in diff_df.iterrows(): for index, item in diff_df.iterrows():
try:
location = { location = {
"type": "Point", "type": "Point",
"coordinates": [item['lng'] / math.pow(10, 10), item['lat'] / math.pow(10, 10)] "coordinates": [item['lng'] / math.pow(10, 10), item['lat'] / math.pow(10, 10)]
@@ -283,7 +284,7 @@ def calc(city, year_month):
city = item['city'] city = item['city']
region = item['region'] region = item['region']
name = item['name'] name = item['name']
estate_type2 = item['estate_type2'] estate_type2 = item['estate_type2'] if pd.notna(item['estate_type2']) else None
bed_kind = item['bed_kind'] bed_kind = item['bed_kind']
ret = office_rent_stat_conn.aggregate([ ret = office_rent_stat_conn.aggregate([
{ {
@@ -303,6 +304,9 @@ def calc(city, year_month):
'$limit': 5 '$limit': 5
} }
]); ]);
except Exception as e:
print("Error occurred:", str(e))
print(item)
# 提取 avg_price 的值 # 提取 avg_price 的值
avg_prices = [doc["avg_price"] for doc in ret] avg_prices = [doc["avg_price"] for doc in ret]
# 计算平均值 # 计算平均值