新增小区规模计算
This commit is contained in:
@@ -17,14 +17,14 @@ def calc_percentile(city=None):
|
||||
"""
|
||||
计算消费等级
|
||||
"""
|
||||
sql = "select id, city, region, name, avg_price, total_price, avg_cost, rent_price, relative_price_ranking, finish_building_date, estate_charge, estate_charge_fix, household_count from community_summary"
|
||||
sql = "select id, city, region, name, avg_price, total_price, avg_cost, rent_price, relative_price_ranking, finish_building_date, estate_charge, estate_charge_fix, household_count, build_area from community_summary"
|
||||
if pd.notna(city):
|
||||
sql += " where city='" + city + "'"
|
||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||
community_summary_df['estate_charge_fix'] = community_summary_df['estate_charge'].combine_first(community_summary_df['estate_charge_fix'])
|
||||
community_summary_df['relative_price_ranking'] = community_summary_df['relative_price_ranking'] * 100
|
||||
consumption_aim_df = community_summary_df[['id', 'city', 'avg_price', 'total_price', 'avg_cost', 'rent_price', 'relative_price_ranking', 'finish_building_date',
|
||||
'estate_charge_fix', 'household_count']]
|
||||
'estate_charge_fix', 'household_count', 'build_area']]
|
||||
number = []
|
||||
for i in range(1, 101):
|
||||
number.append(i / 100)
|
||||
@@ -78,6 +78,24 @@ def calc_percentile(city=None):
|
||||
else:
|
||||
db_column = column + '_percentile'
|
||||
row[db_column] = int(item[column + '_percentile'])
|
||||
# 根据百分位计算小区规模,优先户数,然后根据建筑面积
|
||||
if 'household_count_percentile' in item and pd.notna(item['household_count_percentile']):
|
||||
if item['household_count_percentile'] <= 33:
|
||||
row['scale'] = '小'
|
||||
elif item['household_count_percentile'] <= 66:
|
||||
row['scale'] = '中'
|
||||
else:
|
||||
row['scale'] = '大'
|
||||
if 'scale' not in row:
|
||||
if 'build_area_percentile' in item and pd.notna(item['build_area_percentile']):
|
||||
if item['build_area_percentile'] <= 33:
|
||||
row['scale'] = '小'
|
||||
elif item['build_area_percentile'] <= 66:
|
||||
row['scale'] = '中'
|
||||
else:
|
||||
row['scale'] = '大'
|
||||
if 'build_area_percentile' in item:
|
||||
del row['build_area_percentile']
|
||||
|
||||
action = {'_op_type': 'update',
|
||||
'_index': index_name,
|
||||
|
||||
Reference in New Issue
Block a user