新增估值统计

This commit is contained in:
Jian Shen
2022-08-12 16:13:11 +08:00
parent 5918e5c3d1
commit f7c1318b08
4 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ with DAG(
) as dag:
t1 = BashOperator(
task_id='district_count_thirdavg_deal',
bash_command='python /opt/airflow/dags/repo/dags/stat/evaluate/district_count_thirdavg_deal.py',
bash_command='python /opt/airflow/dags/repo/dags/stat/evaluate/district_count_thirdavg_deal.py {{dag_run.conf["city_num"] if "city_num" in dag_run.conf}}',
)
t2 = BashOperator(
task_id='district_sell_property',
@@ -6,10 +6,18 @@ from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, dateutils
import pandas as pd
import datetime
import os
import sys
log = logging.getLogger(__name__)
df = pd.read_excel('/opt/airflow/dags/repo/dags/stat/evaluate/data/估值数据统计.xlsx')
city_num = sys.argv[1] if len(sys.argv) > 1 else None
print("输出参数" + city_num)
df = pd.DataFrame()
if city_num == 92:
df = pd.read_excel('/opt/airflow/dags/repo/dags/stat/evaluate/data/估值92城市数据统计.xlsx')
else:
df = pd.read_excel('/opt/airflow/dags/repo/dags/stat/evaluate/data/估值数据统计.xlsx')
year_month_day = dateutils.format_date(datetime.datetime.now())
path = "/home/airflow/data/evaluate"
aim_file_name = path + '/估值数据统计结果' + year_month_day + '.xlsx'
+2 -2
View File
@@ -42,7 +42,7 @@ def sell_stat():
'_id'].transform('size')
sell_seaweed_merge_df = sell_seaweed_merge_df[['city', 'region', '_id', 'count']]
sell_seaweed_merge_df = sell_seaweed_merge_df.drop_duplicates(subset=['city', 'region', '_id'])
sell_seaweed_ok_df = sell_seaweed_merge_df[sell_seaweed_merge_df['count'] > 3]
sell_seaweed_ok_df = sell_seaweed_merge_df[sell_seaweed_merge_df['count'] >= 3]
sell_seaweed_ok_df['city_seaweed_count'] = sell_seaweed_ok_df.groupby('city')['city'].transform('size')
city_seaweed_count_df = sell_seaweed_ok_df[['city', 'city_seaweed_count']].drop_duplicates(
subset=['city', 'city_seaweed_count'])
@@ -77,7 +77,7 @@ def sell_stat():
try:
sql = "select count(*) from latest_seawater where city='" + city + "' and region='" + region + "' and cat='sell' and district_name in(" + names_str + ") and p_date > " + one_year_time
num = es206_client.search_by_sql(sql)['hits']['total']['value']
if num > 3:
if num >= 3:
count += 1
total_num += num
all_num += num