From d4fdc751467223b7a5dd7629ec9f43fa25627ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E8=89=B3?= Date: Tue, 28 Oct 2025 13:23:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/office/rent/price.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dags/office/rent/price.py b/dags/office/rent/price.py index 935f0c3..645c42c 100644 --- a/dags/office/rent/price.py +++ b/dags/office/rent/price.py @@ -42,7 +42,7 @@ def calc(city, year_month): dateutils.format_date(dateutils.add_months(dateutils.parse_date(str(year_month), '%Y%m'), months=-1), '%Y%m')) if pd.isna(city_price): # 处理均价为空情况,用上月均价替代 - stat = office_rent_stat_conn.find_one({'city': city, 'cat': 'city', 'date': last_month}) + stat = office_rent_stat_conn.find_one({'city': city, 'cat': 'city', 'date': int(last_month)}) if pd.isna(stat): return False last_month_city_price = stat['avg_price'] @@ -51,8 +51,8 @@ def calc(city, year_month): city_price = last_month_city_price # 写入MONGODB - action = UpdateOne({'city': city, 'cat': 'city', 'date': year_month}, - {'$set': {'city': city, 'cat': 'city', 'date': year_month, 'avg_price': city_price, + action = UpdateOne({'city': city, 'cat': 'city', 'date': int(year_month)}, + {'$set': {'city': city, 'cat': 'city', 'date': int(year_month), 'avg_price': city_price, 'updated_date': datetime.now()}}, upsert=True)