新增财力评级分布图
This commit is contained in:
@@ -1,19 +1,30 @@
|
||||
"""
|
||||
月消费潜力、评级计算
|
||||
"""
|
||||
from goojia_utils import ElasticSearchClient, dateutils
|
||||
from goojia_utils import ElasticSearchClient, dateutils, nextcloudutils, dingutils
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import logging
|
||||
import os
|
||||
import requests
|
||||
from elasticsearch import helpers
|
||||
|
||||
from sklearn.mixture import GaussianMixture
|
||||
from matplotlib import pyplot
|
||||
|
||||
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"
|
||||
save_path_prefix = "/home/airflow/data/community"
|
||||
|
||||
save_png_path = save_path_prefix + "/consumption_rating"
|
||||
if not os.path.exists(save_png_path):
|
||||
os.makedirs(save_png_path)
|
||||
|
||||
nextcloud_aim_file_path = '共享/财力评级/财力评级分布图'
|
||||
|
||||
|
||||
factor_df = pd.read_excel(path + '/财力评级极值设置.xlsx')
|
||||
factor_dict = dict()
|
||||
@@ -23,6 +34,8 @@ for index, item in factor_df.iterrows():
|
||||
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):
|
||||
"""
|
||||
计算消费潜力
|
||||
@@ -137,4 +150,21 @@ def sync(city=None):
|
||||
calc_consumption_rating(community_summary_df)
|
||||
|
||||
|
||||
def save_png(city=None):
|
||||
"""
|
||||
生成财力评级图表
|
||||
"""
|
||||
sql = "select id, city, region, name, consumption_rating from community_summary"
|
||||
if pd.notna(city):
|
||||
sql += " where city='" + city + "'"
|
||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||
|
||||
for city in community_summary_df['city'].unique():
|
||||
community_summary_df[(community_summary_df['consumption_rating'].notna()) & (community_summary_df['city'] == city)]['consumption_rating'].hist(bins=100)
|
||||
pyplot.savefig(save_png_path + "/" + city + ".png")
|
||||
|
||||
|
||||
sync()
|
||||
save_png()
|
||||
nextcloudutils.up_to_nextcloud(save_png_path, nextcloud_aim_file_path)
|
||||
dingutils.send_text("【分布图生成完毕】财力评级已完成, 请点击 https://nextcloud.fangjia.com/s/CQdTiH9zW4tFs7T 查看分布图", "c7ac6c86bfbe49a95e30a68616c4d784ae7781c715430dc9c5f6b46d3e6ebd78")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
nextcloud-api-wrapper
|
||||
elasticsearch==7.11.0
|
||||
transbigdata==0.4.15
|
||||
pykalman==0.9.5
|
||||
|
||||
Reference in New Issue
Block a user