From 069f0943f021d16e0d4bd40712fb0c063c7dec6d Mon Sep 17 00:00:00 2001 From: "shenjian@fangjia.com" Date: Tue, 22 Nov 2022 14:29:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=84=E7=BA=A7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/community/consumption.py | 63 +++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/dags/business/business/community/consumption.py b/dags/business/business/community/consumption.py index ebc905a..11ffab3 100644 --- a/dags/business/business/community/consumption.py +++ b/dags/business/business/community/consumption.py @@ -10,7 +10,6 @@ from elasticsearch import helpers import matplotlib.pyplot as plt from sklearn.mixture import GaussianMixture -from matplotlib import pyplot log = logging.getLogger(__name__) @@ -180,48 +179,48 @@ def filter_min_max(city, community_summary_df): return community_summary_df -def save_png(city=None): +def save_png(city): """ 生成财力评级图表 """ - sql = "select id, city, region, name, total_price, estate_charge, avg_cost, relative_price_ranking, consumption_rating from community_summary" - if pd.notna(city): - sql += " where city='" + city + "'" + sql = "select id, city, region, name, total_price, estate_charge, avg_cost, relative_price_ranking, consumption_rating from community_summary where city='" + city + "'" community_summary_df = es206_client.scan_by_sql_to_data_frame(sql) community_summary_df['total_price'] = community_summary_df['total_price'] / 10000 - for city in community_summary_df['city'].unique(): - community_city = community_summary_df[community_summary_df['city'] == city] - community_city = filter_min_max(city, community_city).copy() + community_city = filter_min_max(city, community_summary_df).copy() - plt.subplot(3, 1, 1) - community_city['consumption_rating'].hist(bins=100) - plt.xlabel('consumption_rating') - plt.tight_layout() + plt.subplot(3, 1, 1) + community_city['consumption_rating'].hist(bins=100) + plt.xlabel('consumption_rating') + plt.tight_layout() - plt.subplot(3, 2, 3) - community_city['total_price'].hist(bins=100) - plt.xlabel('total_price') - plt.tight_layout() + plt.subplot(3, 2, 3) + community_city['total_price'].hist(bins=100) + plt.xlabel('total_price') + plt.tight_layout() - plt.subplot(3, 2, 4) - community_city['estate_charge'].hist(bins=100) - plt.xlabel('estate_charge') - plt.tight_layout() + plt.subplot(3, 2, 4) + community_city['estate_charge'].hist(bins=100) + plt.xlabel('estate_charge') + plt.tight_layout() - plt.subplot(3, 2, 5) - community_city['avg_cost'].hist(bins=100) - plt.xlabel('avg_cost') - plt.tight_layout() + plt.subplot(3, 2, 5) + community_city['avg_cost'].hist(bins=100) + plt.xlabel('avg_cost') + plt.tight_layout() - plt.subplot(3, 2, 6) - community_city['relative_price_ranking'].hist(bins=100) - plt.xlabel('relative_price_ranking') - plt.tight_layout() - - plt.savefig(save_png_path + "/" + city + ".png") - plt.show() + plt.subplot(3, 2, 6) + community_city['relative_price_ranking'].hist(bins=100) + plt.xlabel('relative_price_ranking') + plt.tight_layout() + plt.savefig(save_png_path + "/" + city + ".png") + # 清图 + plt.clf() + # 清坐标轴 + plt.cla() + # 关窗口 + plt.close() sync() -dingutils.send_text("【分布图生成完毕】财力评级已完成, 请点击 https://nextcloud.fangjia.com/s/gNTqRqnEnsYkJc4 查看分布图", "c7ac6c86bfbe49a95e30a68616c4d784ae7781c715430dc9c5f6b46d3e6ebd78") +#dingutils.send_text("【分布图生成完毕】财力评级已完成, 请点击 https://nextcloud.fangjia.com/s/gNTqRqnEnsYkJc4 查看分布图", "c7ac6c86bfbe49a95e30a68616c4d784ae7781c715430dc9c5f6b46d3e6ebd78")