优化全量统计
This commit is contained in:
@@ -33,36 +33,7 @@ def calculate_confidence(row):
|
|||||||
return "低"
|
return "低"
|
||||||
|
|
||||||
|
|
||||||
def stat(city):
|
def stat(community_summary_df):
|
||||||
if pd.notna(city):
|
|
||||||
query = {
|
|
||||||
"bool": {
|
|
||||||
"must": [
|
|
||||||
{
|
|
||||||
"terms": {
|
|
||||||
"city": [city]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
query = {
|
|
||||||
"bool": {
|
|
||||||
"must": [
|
|
||||||
{
|
|
||||||
"match_all": {}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
community_summary_df = es206_client.scan_to_data_frame(query={"query": query}, source=[
|
|
||||||
"city",
|
|
||||||
"region",
|
|
||||||
"consumption_rating",
|
|
||||||
"price_rating",
|
|
||||||
"consumption_score"
|
|
||||||
], index="community_summary")
|
|
||||||
# 计算置信度
|
# 计算置信度
|
||||||
community_summary_df["置信度"] = community_summary_df.apply(calculate_confidence, axis=1)
|
community_summary_df["置信度"] = community_summary_df.apply(calculate_confidence, axis=1)
|
||||||
grouped = community_summary_df.groupby(["city", "region"])
|
grouped = community_summary_df.groupby(["city", "region"])
|
||||||
@@ -181,7 +152,8 @@ def detail(city):
|
|||||||
community_summary_df.to_csv(save_png_path + '/' + aim_file, index=False, columns=["城市", "区域", "小区名称", "财力分数", "财力评级", "户均总价评级", "差值", "户均总价", "小区均价", "计算方式", "典型面积",
|
community_summary_df.to_csv(save_png_path + '/' + aim_file, index=False, columns=["城市", "区域", "小区名称", "财力分数", "财力评级", "户均总价评级", "差值", "户均总价", "小区均价", "计算方式", "典型面积",
|
||||||
"获取方式", "相对价格排名", "人均消费", "物业费", "物业费获取方式", '置信度'])
|
"获取方式", "相对价格排名", "人均消费", "物业费", "物业费获取方式", '置信度'])
|
||||||
nextcloudutils.up_to_nextcloud(save_png_path + "/" + aim_file, nextcloud_aim_file_path + "/" + aim_file)
|
nextcloudutils.up_to_nextcloud(save_png_path + "/" + aim_file, nextcloud_aim_file_path + "/" + aim_file)
|
||||||
|
# 减少重复查询
|
||||||
|
stat(community_summary_df)
|
||||||
dingutils.send_text("【统计】财力评级统计完毕,请点击 https://nextcloud.fangjia.com/s/nMbzk6ZKJDimapf 查看", "32400b949005817550937f82a82c064fe5be65c23204306442c15e8b485d7ef2")
|
dingutils.send_text("【统计】财力评级统计完毕,请点击 https://nextcloud.fangjia.com/s/nMbzk6ZKJDimapf 查看", "32400b949005817550937f82a82c064fe5be65c23204306442c15e8b485d7ef2")
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +161,6 @@ sys_city = sys.argv[1] if len(sys.argv) > 1 else None
|
|||||||
if pd.notna(sys_city) and "," in sys_city:
|
if pd.notna(sys_city) and "," in sys_city:
|
||||||
cities = sys_city.split(",")
|
cities = sys_city.split(",")
|
||||||
for city in cities:
|
for city in cities:
|
||||||
stat(city)
|
|
||||||
detail(city)
|
detail(city)
|
||||||
else:
|
else:
|
||||||
stat(sys_city)
|
stat(sys_city)
|
||||||
|
|||||||
Reference in New Issue
Block a user