美团中间表改造
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
租金、均价导出
|
||||
"""
|
||||
|
||||
from goojia_utils import MAIN_MONGO_CLIENT, dateutils, commutils
|
||||
from goojia_utils import MAIN_MONGO_CLIENT, dateutils, commutils, ClickHouseClient
|
||||
import pandas as pd
|
||||
import datetime
|
||||
import logging
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
#district_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'district_stat')
|
||||
# 月度均价表
|
||||
district_sell_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'district_sell_stat')
|
||||
sqmetre_rent_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'sqmetre_rent')
|
||||
tmp_ck = ClickHouseClient(database='tmp')
|
||||
|
||||
|
||||
city_df = pd.read_excel('/opt/airflow/dags/repo/dags/mt/supply/data/美团88城市列表.xlsx')
|
||||
@@ -22,7 +22,8 @@ path = "/home/airflow/data/mt"
|
||||
|
||||
output_date = sys.argv[1] if len(sys.argv) > 1 else dateutils.format_date(datetime.datetime.now(), '%Y%m')
|
||||
|
||||
seaweed_new_result_df = pd.read_csv(path + '/FJW_COMM_' + output_date + '.csv', sep='@', encoding='utf-8')
|
||||
seaweed_new_result_df = tmp_ck.read_sql_query("select * from mt_community")
|
||||
|
||||
if 'avg_price' in seaweed_new_result_df:
|
||||
seaweed_new_result_df = seaweed_new_result_df.drop(columns=['avg_price', 'rent_price'])
|
||||
|
||||
@@ -111,4 +112,9 @@ result_df['ignore_comm'] = None
|
||||
result_df = result_df.apply(lambda x: format_rent(x), axis=1)
|
||||
result_df = result_df[result_df['ignore_comm'] != 1]
|
||||
|
||||
result_df.to_csv(path + '/FJW_COMM_' + output_date + '.csv', sep='@', encoding='utf-8', index=False)
|
||||
del result_df['ignore_comm']
|
||||
|
||||
ck_delete_sql = "ALTER TABLE tmp.mt_community DELETE WHERE 1=1 "
|
||||
tmp_ck.execute(ck_delete_sql)
|
||||
|
||||
tmp_ck.to_sql_plus(result_df, 'mt_community')
|
||||
|
||||
Reference in New Issue
Block a user