diff --git a/dags/office/rent/base_price.py b/dags/office/rent/base_price.py index 76dcfbb..620e0e3 100644 --- a/dags/office/rent/base_price.py +++ b/dags/office/rent/base_price.py @@ -79,7 +79,7 @@ def calc(city, year_month): } estate_type2 = item['estate_type2'] if pd.notna(item['estate_type2']) else None bed_kind = item['bed_kind'] if pd.notna(item['bed_kind']) else None - action = UpdateOne({'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name}, + action = UpdateOne({'cat': 'office', 'city': city, 'district': region, 'name': name, 'date': year_month}, {'$set': {'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name, 'avg_price': avg_price, 'estate_type2': estate_type2, 'bed_kind': bed_kind, 'location': location, @@ -135,7 +135,7 @@ def calc(city, year_month): average_price = np.mean(avg_prices) if len(avg_prices) > 0 else 0 if average_price > 0: avg_price = round(average_price, 2) - action = UpdateOne({'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name}, + action = UpdateOne({'cat': 'office', 'city': city, 'district': region, 'name': name, 'date': year_month}, {'$set': {'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name, 'avg_price': avg_price, 'estate_type2': estate_type2, 'bed_kind': bed_kind, @@ -198,7 +198,7 @@ def calc(city, year_month): count += 1 if count > 0: avg_price = round(sum_price / count, 2) - action = UpdateOne({'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name}, + action = UpdateOne({'cat': 'office', 'city': city, 'district': region, 'name': name, 'date': year_month}, {'$set': {'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name, 'avg_price': avg_price, 'estate_type2': estate_type2, 'bed_kind': None, @@ -236,7 +236,7 @@ def calc(city, year_month): count += 1 if count > 0: avg_price = round(sum_price / count, 2) - action = UpdateOne({'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name}, + action = UpdateOne({'cat': 'office', 'city': city, 'district': region, 'name': name, 'date': year_month}, {'$set': {'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name, 'avg_price': avg_price, 'estate_type2': None, 'bed_kind': bed_kind, @@ -286,7 +286,7 @@ def calc(city, year_month): average_price = np.mean(avg_prices) if len(avg_prices) > 0 else 0 if average_price > 0: avg_price = round(average_price, 2) - action = UpdateOne({'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name}, + action = UpdateOne({'cat': 'office', 'city': city, 'district': region, 'name': name, 'date': year_month}, {'$set': {'city': city, 'cat': 'office', 'date': year_month, 'district': region, 'name': name, 'avg_price': avg_price, 'estate_type2': estate_type2, 'bed_kind': None, @@ -299,4 +299,5 @@ def calc(city, year_month): actions.clear() office_rent_stat_conn.bulk_write(actions) -calc('上海', 202412) \ No newline at end of file +for year_month in range(202406, 202501): + calc('上海', year_month) \ No newline at end of file