回退相对价格排名优化

This commit is contained in:
shenjian@fangjia.com
2023-05-16 16:20:00 +08:00
parent 036a6791a7
commit d82c2f1b2b
2 changed files with 5 additions and 5 deletions
@@ -34,7 +34,7 @@ def calc_consumption_potential(city):
"""
计算消费潜力
"""
sql = "select id, city, region, name, total_price, estate_charge, estate_charge_fix, relative_price_ranking, relative_price_ranking_fix, avg_cost from community_summary where city='" + city + "'"
sql = "select id, city, region, name, total_price, estate_charge, estate_charge_fix, relative_price_ranking, avg_cost from community_summary where city='" + city + "'"
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
columns = community_summary_df.columns
if 'total_price' not in columns or 'estate_charge' not in columns or 'relative_price_ranking' not in columns or 'avg_cost' not in columns:
@@ -70,9 +70,9 @@ def calc_consumption_potential(city):
np.std)
community_summary_df['relative_price_ranking_mean'] = community_summary_df.groupby(by=['city'])[
'relative_price_ranking_fix'].transform(np.mean)
'relative_price_ranking'].transform(np.mean)
community_summary_df['relative_price_ranking_std'] = community_summary_df.groupby(by=['city'])[
'relative_price_ranking_fix'].transform(np.std)
'relative_price_ranking'].transform(np.std)
community_summary_df['avg_cost_mean'] = community_summary_df.groupby(by=['city'])['avg_cost_fixed'].transform(np.mean)
community_summary_df['avg_cost_std'] = community_summary_df.groupby(by=['city'])['avg_cost_fixed'].transform(np.std)
@@ -89,7 +89,7 @@ def calc_consumption_potential(city):
community_summary_df['estate_charge_score'] = 0
if community_summary_df['relative_price_ranking_std'].unique()[0] != 0:
community_summary_df['relative_price_ranking_score'] = 21.8427926 * (community_summary_df['relative_price_ranking_fix'] - community_summary_df['relative_price_ranking_mean']) / community_summary_df['relative_price_ranking_std']
community_summary_df['relative_price_ranking_score'] = 21.8427926 * (community_summary_df['relative_price_ranking'] - community_summary_df['relative_price_ranking_mean']) / community_summary_df['relative_price_ranking_std']
else:
community_summary_df['relative_price_ranking_score'] = 0
+1 -1
View File
@@ -111,4 +111,4 @@ with DAG(
bash_command='python /opt/airflow/dags/repo/dags/business/business/community/other.py {{dag_run.conf["city"] if "city" in dag_run.conf}}',
)
# 人均消费并行,值为空
comm >> price >> [avg_cost, total_price, relative_price_ranking, estate_charge_complete] >> total_price_complete >> relative_price_ranking_fix >> consumption >> city_level_and_price_rating >> credit >> [estate_charge_ranking, price_rating, person_rating, percentile] >> sell >> trade >> [traffic, business_district, medical, life, education] >> education2 >> extra >> other
comm >> price >> [avg_cost, total_price, relative_price_ranking, estate_charge_complete] >> total_price_complete >> consumption >> city_level_and_price_rating >> credit >> [estate_charge_ranking, price_rating, person_rating, percentile] >> sell >> trade >> [traffic, business_district, medical, life, education] >> education2 >> extra >> other