添加肉

This commit is contained in:
2025-07-05 22:35:42 +08:00
parent 93c5d9501b
commit e31aaf6794
+4 -3
View File
@@ -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}