diff --git a/dags/office/rent/price.py b/dags/office/rent/price.py index 8e8611d..935f0c3 100644 --- a/dags/office/rent/price.py +++ b/dags/office/rent/price.py @@ -64,7 +64,7 @@ def calc(city, year_month): avg_price = region_avg_prices[region] else: # 处理均价为空情况,用上月均价替代 - district_stat = office_rent_stat_conn.find_one({'city': city, 'cat': 'district', 'date': last_month, 'district': region}) + district_stat = office_rent_stat_conn.find_one({'city': city, 'cat': 'district', 'date': int(last_month), 'district': region}) if pd.isna(district_stat): continue last_month_region_price = district_stat['avg_price'] @@ -72,8 +72,8 @@ def calc(city, year_month): continue avg_price = last_month_region_price - action = UpdateOne({'city': city, 'cat': 'district', 'date': year_month, 'district': region}, - {'$set': {'city': city, 'cat': 'district', 'date': year_month, 'district': region, + action = UpdateOne({'city': city, 'cat': 'district', 'date': int(year_month), 'district': region}, + {'$set': {'city': city, 'cat': 'district', 'date': int(year_month), 'district': region, 'avg_price': round(avg_price, 2), 'updated_date': datetime.now()}}, upsert=True) actions.append(action)