新增统计
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""
|
||||
统计各城市租金、价格等其他字段覆盖率
|
||||
"""
|
||||
import pandas as pd
|
||||
from goojia_utils import dateutils
|
||||
import datetime
|
||||
|
||||
path = "/home/airflow/data/mt"
|
||||
|
||||
result_df = pd.read_csv(path + '/FJW_COMM_' + dateutils.format_date(datetime.datetime.now(), '%Y%m') + '.csv', sep='@', encoding='utf-8')
|
||||
|
||||
city_df = pd.read_excel('/opt/airflow/dags/repo/dags/mt/supply/data/美团19城市列表.xlsx')
|
||||
cities = city_df['城市列表'].values.tolist()
|
||||
|
||||
actions = list()
|
||||
for city in cities:
|
||||
action = dict()
|
||||
for item in result_df.columns:
|
||||
temp_df = result_df[result_df['city'] == city]
|
||||
action[item] = round(len(temp_df[temp_df[item].notna()]) * 100 / len(temp_df), 2)
|
||||
action[city] = city
|
||||
if action['rent_price'] < 90:
|
||||
action['rent_flag'] = '租金覆盖率低于90%'
|
||||
if action['avg_price'] < 90:
|
||||
action['avg_flag'] = '价格覆盖率低于90%'
|
||||
|
||||
df = pd.DataFrame(actions)
|
||||
aim_file_name = path + "/" + dateutils.format_date(datetime.datetime.now(), '%Y%m') + '覆盖率统计.xlsx'
|
||||
df.to_excel(aim_file_name)
|
||||
|
||||
def up_to_nextcloud():
|
||||
"""
|
||||
上传统计信息至nextcloud
|
||||
"""
|
||||
from nextcloud import NextCloud
|
||||
NEXTCLOUD_URL = "https://nextcloud.fangjia.com"
|
||||
NEXTCLOUD_USERNAME = "shenjian@fangjia.com"
|
||||
NEXTCLOUD_PASSWORD = "goojia123456"
|
||||
aim_file_path = '共享/美团/' + dateutils.format_date(datetime.datetime.now(), '%Y%m') + '覆盖率统计.xlsx'
|
||||
nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD, json_output=True)
|
||||
nxc.upload_file(aim_file_name, aim_file_path)
|
||||
|
||||
up_to_nextcloud()
|
||||
# https://oapi.dingtalk.com/robot/send?access_token=e022515642e544942f86bbe234448edc3b8bddea8184e63b7edf4129b31c8e79
|
||||
Reference in New Issue
Block a user