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)