From e31aaf6794b17e641960e003489bfbea5cf9cf6a Mon Sep 17 00:00:00 2001 From: wangwenyan Date: Sat, 5 Jul 2025 22:35:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=82=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/stat/community/community_rate.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dags/stat/community/community_rate.py b/dags/stat/community/community_rate.py index 2bb30a0..8ff5199 100644 --- a/dags/stat/community/community_rate.py +++ b/dags/stat/community/community_rate.py @@ -265,7 +265,8 @@ def load_comm_stat(city, calc_year_month): sqmetre_rent = pd.DataFrame(list(sqmetre_rent_client.find({"s_date": calc_year_month, "cat": "district", "city": city},{"city": 1, "region": 1, "district_name": 1, "avg_price": 1, "_id": 0}))) sqmetre_rent = sqmetre_rent.rename(columns={"district_name": "name", "avg_price": "sqmetre_rent"}) stat = stat.merge(sqmetre_rent, on=['city', 'region', 'name'], how='left') - stat['rent_to_price_ratio'] = stat['sqmetre_rent'] * 12 / stat['avg_price'] * 100 + stat['roi'] = round(stat['sqmetre_rent'] * 12 / stat['avg_price'] * 100, 2) + stat['rent_to_price_ratio'] =stat['sqmetre_rent'] /stat['avg_price'] stat["org_sqmetre_rent"] = stat['sqmetre_rent'] stat["org_rent_to_price_ratio"] = stat['rent_to_price_ratio'] stat['rent_to_price_ratio'] = stat['rent_to_price_ratio'].fillna(stat['rent_to_price_ratio'].mean()) @@ -503,7 +504,7 @@ def process_city(args): data = load_data_by_city(city, calc_year_month) data = comms_rating(data) db_fields = ["comm_id", "city", "region", "name", 'block', 'block_rating', "address", "sqmetre_rent", "yoy", - "rent_to_price_ratio", "avg_price", "total_score", "community_quality_score", + "rent_to_price_ratio", "roi", "avg_price", "total_score", "community_quality_score", "community_price_score", "location_advantage_score", "flowability_score", "living_facilities_score", "education_score", "hospital_score", "rating", "community_quality_rating", "community_price_rating", "location_advantage_rating", "flowability_rating", "living_facilities_rating", "education_rating", @@ -551,7 +552,7 @@ def process_city(args): del df_simple['region_block'] for score_factor in ['total_score', 'community_quality_score', 'community_price_score','location_advantage_score', 'flowability_score', 'living_facilities_score','education_score', 'hospital_score']: df_simple[score_factor] = df_simple[score_factor].apply(lambda x: round(x, 2)) - df_simple['rent_to_price_ratio'] = df_simple['rent_to_price_ratio'].apply(lambda x: round(x, 2)) + df_simple['rent_to_price_ratio'] = df_simple['rent_to_price_ratio'].apply(lambda x: round(x, 4)) df_simple['yoy'] = df_simple['yoy'].apply(lambda x: round(x, 2)) updater = MongoDataFrameUpdater(community_rate_client) dtype = {"avg_price": int,"build_year": int, 'resistance_coef': int}