新增物业费等级极值过滤

This commit is contained in:
shenjian@fangjia.com
2022-11-21 18:34:34 +08:00
parent 0281a2d5f2
commit 0588704e96
@@ -15,6 +15,13 @@ 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 gmm_train(total_rate, consumption_df, source, target):
@@ -73,7 +80,11 @@ def sync(city=None):
sql = "select id, city, region, name, estate_charge from community_summary"
if pd.notna(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['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']
calc_estate_charge_rating(community_summary_df)
sync()
sync('上海')