新增价格异常检测脚本
This commit is contained in:
@@ -4,9 +4,14 @@
|
||||
from goojia_utils import dateutils, oracle
|
||||
import pandas as pd
|
||||
import logging
|
||||
import os
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
path = "/home/airflow/data/jh/price"
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
month_now = dateutils.format_date(dateutils.add_months(dateutils.datetime.datetime.now()), '%Y%m')
|
||||
month_last = dateutils.format_date(dateutils.add_months(dateutils.datetime.datetime.now(), months=-1), '%Y%m')
|
||||
month_before = dateutils.format_date(dateutils.add_months(dateutils.datetime.datetime.now(), months=-2), '%Y%m')
|
||||
@@ -49,7 +54,10 @@ for key in six_map:
|
||||
result_df = pd.DataFrame(actions)
|
||||
result_df['confidence'] = result_df['confidence'].astype(float)
|
||||
|
||||
excel_writer = pd.ExcelWriter('data/'+ month_now +'VS'+ month_last +'月价格波动大于10%小区.xlsx')
|
||||
file_name = month_now +'VS'+ month_last +'月价格波动大于10%小区.xlsx'
|
||||
aim_file_name = path + '/' + file_name
|
||||
|
||||
excel_writer = pd.ExcelWriter(aim_file_name)
|
||||
|
||||
result_df = result_df.drop_duplicates(subset=['commid'], keep='first')
|
||||
result_df = result_df.rename(columns={'city': '城市', 'region': '区域', 'commid': '小区ID', 'commname': '小区名', 'five_price': '上一月价格',
|
||||
@@ -66,3 +74,18 @@ city_count_df.to_excel(excel_writer, index=False, sheet_name='城市维度')
|
||||
excel_writer.save()
|
||||
excel_writer.close()
|
||||
|
||||
|
||||
def up_to_nextcloud():
|
||||
"""
|
||||
上传统计信息至nextcloud
|
||||
"""
|
||||
from nextcloud import NextCloud
|
||||
NEXTCLOUD_URL = "https://nextcloud.fangjia.com"
|
||||
NEXTCLOUD_USERNAME = "shenjian@fangjia.com"
|
||||
NEXTCLOUD_PASSWORD = "goojia123456"
|
||||
nextcloud_file_name = '共享/建行/' + file_name
|
||||
nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD, json_output=True)
|
||||
nxc.upload_file(aim_file_name, nextcloud_file_name)
|
||||
|
||||
|
||||
up_to_nextcloud()
|
||||
|
||||
Reference in New Issue
Block a user