修复物业费评级bug
This commit is contained in:
@@ -102,16 +102,14 @@ def calc_consumption_rating(community_summary_df):
|
||||
"""
|
||||
consumption_aim_df = community_summary_df[['_id', 'city', 'consumption_potential']]
|
||||
consumption_aim_df = consumption_aim_df.dropna(subset=['consumption_potential'])
|
||||
cities = consumption_aim_df['city'].unique()
|
||||
source = "consumption_potential"
|
||||
target = "consumption_rating"
|
||||
actions = list()
|
||||
count = 0
|
||||
|
||||
for city in cities:
|
||||
df = consumption_aim_df[consumption_aim_df['city'] == city].copy()
|
||||
df = consumption_aim_df.copy()
|
||||
if len(df) < 5:
|
||||
continue
|
||||
return
|
||||
df = gmm_train(5, df, source, target)
|
||||
# 批量更新
|
||||
for index, item in df.iterrows():
|
||||
@@ -140,19 +138,20 @@ def calc_consumption_rating(community_summary_df):
|
||||
log.info("评级完成,共更新: {}".format(count))
|
||||
|
||||
|
||||
def sync(city=None):
|
||||
if pd.isna(city):
|
||||
for city_now in areautils.get_all_cities():
|
||||
def sync_by_city(city_now):
|
||||
log.info(f"{city_now}开始评级....")
|
||||
community_summary_df = calc_consumption_potential(city_now)
|
||||
calc_consumption_rating(community_summary_df)
|
||||
save_png(city_now)
|
||||
nextcloudutils.up_to_nextcloud(save_png_path, nextcloud_aim_file_path)
|
||||
|
||||
|
||||
def sync(city=None):
|
||||
if pd.isna(city):
|
||||
for city_now in areautils.get_all_cities():
|
||||
sync_by_city(city_now)
|
||||
else:
|
||||
community_summary_df = calc_consumption_potential(city)
|
||||
calc_consumption_rating(community_summary_df)
|
||||
save_png(city)
|
||||
nextcloudutils.up_to_nextcloud(save_png_path, nextcloud_aim_file_path)
|
||||
sync_by_city(city)
|
||||
|
||||
|
||||
def filter_min_max(city, community_summary_df):
|
||||
|
||||
@@ -63,16 +63,14 @@ def calc_estate_charge_rating(community_summary_df):
|
||||
"""
|
||||
consumption_aim_df = community_summary_df[['_id', 'city', 'estate_charge']]
|
||||
consumption_aim_df = consumption_aim_df.dropna(subset=['estate_charge'])
|
||||
cities = consumption_aim_df['city'].unique()
|
||||
source = "estate_charge"
|
||||
target = "estate_charge_ranking"
|
||||
actions = list()
|
||||
count = 0
|
||||
|
||||
for city in cities:
|
||||
df = consumption_aim_df[consumption_aim_df['city'] == city].copy()
|
||||
df = consumption_aim_df.copy()
|
||||
if len(df) < 5:
|
||||
continue
|
||||
return
|
||||
df = gmm_train(5, df, source, target)
|
||||
# 批量更新
|
||||
for index, item in df.iterrows():
|
||||
@@ -108,6 +106,7 @@ def sync_by_city(city_now):
|
||||
save_png(city_now)
|
||||
nextcloudutils.up_to_nextcloud(save_png_path, nextcloud_aim_file_path)
|
||||
|
||||
|
||||
def sync(city=None):
|
||||
if pd.isna(city):
|
||||
for city_now in areautils.get_all_cities():
|
||||
@@ -121,7 +120,24 @@ def save_png(city=None):
|
||||
生成财力评级图表
|
||||
"""
|
||||
sql = "select id, city, region, name, consumption_rating from community_summary where city='" + city + "'"
|
||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||
community_city = es206_client.scan_by_sql_to_data_frame(sql)
|
||||
plt.subplot(2, 1, 1)
|
||||
community_city['estate_charge_ranking'].hist(bins=100)
|
||||
plt.xlabel('estate_charge_ranking')
|
||||
plt.tight_layout()
|
||||
|
||||
plt.subplot(2, 1, 2)
|
||||
community_city['estate_charge'].hist(bins=100)
|
||||
plt.xlabel('estate_charge')
|
||||
plt.tight_layout()
|
||||
|
||||
plt.savefig(save_png_path + "/" + city + ".png")
|
||||
# 清图
|
||||
plt.clf()
|
||||
# 清坐标轴
|
||||
plt.cla()
|
||||
# 关窗口
|
||||
plt.close()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user