修改财力评级计算方式
This commit is contained in:
@@ -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, avg_cost from community_summary where city='" + 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 + "'"
|
||||
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'].transform(np.mean)
|
||||
'relative_price_ranking_fix'].transform(np.mean)
|
||||
community_summary_df['relative_price_ranking_std'] = community_summary_df.groupby(by=['city'])[
|
||||
'relative_price_ranking'].transform(np.std)
|
||||
'relative_price_ranking_fix'].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'] - 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_fix'] - community_summary_df['relative_price_ranking_mean']) / community_summary_df['relative_price_ranking_std']
|
||||
else:
|
||||
community_summary_df['relative_price_ranking_score'] = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user