diff --git a/dags/business/business/community/consumption.py b/dags/business/business/community/consumption.py index 36154db..fa3c5b8 100644 --- a/dags/business/business/community/consumption.py +++ b/dags/business/business/community/consumption.py @@ -13,7 +13,15 @@ log = logging.getLogger(__name__) es206_client = ElasticSearchClient(host='192.168.0.206') index_name = "community_summary" +path = "/opt/airflow/dags/repo/dags/business/business/community/data" +factor_df = pd.read_excel(path + '/财力评级极值设置.xlsx') +factor_dict = dict() +for index, item in factor_df.iterrows(): + if pd.isna(item['min_total_price']): + continue + factor_dict[item['city']] = {'min_total_price': item['min_total_price'], 'max_total_price': item['max_total_price'], 'min_estate_charge': item['min_estate_charge'], 'max_estate_charge': item['max_estate_charge'], \ + 'min_avg_cost': item['min_avg_cost'], 'max_avg_cost': item['max_avg_cost']} def calc_consumption_potential(city): """ @@ -24,6 +32,15 @@ def calc_consumption_potential(city): sql += " where city='" + city + "'" community_summary_df = es206_client.scan_by_sql_to_data_frame(sql) # 户均总价计算时候改成万 + ### 极值设置 + if city in factor_dict: + community_summary_df.loc[community_summary_df['total_price'] < factor_dict[city]['min_total_price'], 'total_price'] = factor_dict[city]['min_total_price'] + community_summary_df.loc[community_summary_df['total_price'] > factor_dict[city]['max_total_price'], 'total_price'] = factor_dict[city]['max_total_price'] + community_summary_df.loc[community_summary_df['estate_charge'] < factor_dict[city]['min_estate_charge'], 'estate_charge'] = factor_dict[city]['min_estate_charge'] + community_summary_df.loc[community_summary_df['estate_charge'] > factor_dict[city]['max_estate_charge'], 'estate_charge'] = factor_dict[city]['max_estate_charge'] + community_summary_df.loc[community_summary_df['avg_cost'] < factor_dict[city]['min_avg_cost'], 'avg_cost'] = factor_dict[city]['min_avg_cost'] + community_summary_df.loc[community_summary_df['avg_cost'] > factor_dict[city]['max_avg_cost'], 'avg_cost'] = factor_dict[city]['max_avg_cost'] + community_summary_df['total_price'] = community_summary_df['total_price'] / 10000 community_summary_df['total_price_mean'] = community_summary_df.groupby(by=['city'])['total_price'].transform( @@ -119,5 +136,4 @@ def sync(city=None): community_summary_df = calc_consumption_potential(city) calc_consumption_rating(community_summary_df) - sync() diff --git a/dags/business/business/community/data/财力评级极值设置.xlsx b/dags/business/business/community/data/财力评级极值设置.xlsx new file mode 100644 index 0000000..df58ecd Binary files /dev/null and b/dags/business/business/community/data/财力评级极值设置.xlsx differ