租金BUG修复
This commit is contained in:
@@ -276,33 +276,37 @@ 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():
|
||||||
location = {
|
try:
|
||||||
"type": "Point",
|
location = {
|
||||||
"coordinates": [item['lng'] / math.pow(10, 10), item['lat'] / math.pow(10, 10)]
|
"type": "Point",
|
||||||
}
|
"coordinates": [item['lng'] / math.pow(10, 10), item['lat'] / math.pow(10, 10)]
|
||||||
city = item['city']
|
|
||||||
region = item['region']
|
|
||||||
name = item['name']
|
|
||||||
estate_type2 = item['estate_type2']
|
|
||||||
bed_kind = item['bed_kind']
|
|
||||||
ret = office_rent_stat_conn.aggregate([
|
|
||||||
{
|
|
||||||
'$geoNear': {
|
|
||||||
'near': location,
|
|
||||||
'distanceField': "distance",
|
|
||||||
'maxDistance': 3000,
|
|
||||||
'spherical': True
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'$match': {
|
|
||||||
'date': year_month
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'$limit': 5
|
|
||||||
}
|
}
|
||||||
]);
|
city = item['city']
|
||||||
|
region = item['region']
|
||||||
|
name = item['name']
|
||||||
|
estate_type2 = item['estate_type2'] if pd.notna(item['estate_type2']) else None
|
||||||
|
bed_kind = item['bed_kind']
|
||||||
|
ret = office_rent_stat_conn.aggregate([
|
||||||
|
{
|
||||||
|
'$geoNear': {
|
||||||
|
'near': location,
|
||||||
|
'distanceField': "distance",
|
||||||
|
'maxDistance': 3000,
|
||||||
|
'spherical': True
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'$match': {
|
||||||
|
'date': year_month
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'$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]
|
||||||
# 计算平均值
|
# 计算平均值
|
||||||
|
|||||||
Reference in New Issue
Block a user