新增69个城市阈值
This commit is contained in:
+48
-41
@@ -16,8 +16,6 @@ path = "/home/airflow/data/mt"
|
||||
|
||||
output_date = sys.argv[1] if 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')
|
||||
|
||||
month_start = dateutils.format_date(dateutils.add_months(dateutils.parse_date(output_date, '%Y%m'), months=-1), '%Y%m') + '01'
|
||||
curr_month_start = output_date + '01'
|
||||
logging.info("日期信息:" + month_start + ' ' + curr_month_start)
|
||||
@@ -76,53 +74,62 @@ district_facilitys_new_df = district_facilitys_new_df.rename(columns={'district_
|
||||
district_facilitys_new_df = district_facilitys_new_df.drop_duplicates(subset=['city', 'region', 'name'], keep='first')
|
||||
|
||||
result_df = pd.read_csv(path + '/FJW_COMM_' + output_date + '.csv', sep='@', encoding='utf-8')
|
||||
if 'school' in result_df.columns:
|
||||
result_df = result_df.drop(columns=['school', 'bank', 'hospital', 'market', 'subway'])
|
||||
|
||||
result_df = pd.merge(result_df, district_facilitys_new_df, how='left', on=['city', 'region', 'name'])
|
||||
result_df.loc[:, 'district_facilitys'] = None
|
||||
|
||||
|
||||
# 剔除特别大的
|
||||
def format_facilitys(x):
|
||||
if type(x['school']) is not int:
|
||||
x.school = 0
|
||||
else:
|
||||
if x.school > 10:
|
||||
x.school = 10
|
||||
|
||||
if type(x['bank']) is not int:
|
||||
x.bank = 0
|
||||
else:
|
||||
if x.bank > 30:
|
||||
x.bank = 30
|
||||
|
||||
if type(x['hospital']) is not int:
|
||||
x.hospital = 0
|
||||
else:
|
||||
if x.hospital > 10:
|
||||
x.hospital = 10
|
||||
if type(x['market']) is not int:
|
||||
x.market = 0
|
||||
else:
|
||||
if x.market > 15:
|
||||
x.market = 15
|
||||
|
||||
if type(x['subway']) is not int:
|
||||
x.subway = 0
|
||||
else:
|
||||
if x.subway > 5:
|
||||
x.subway = 5
|
||||
|
||||
# 对于存在周边配套的输出字段
|
||||
info = list()
|
||||
if x.school > 0:
|
||||
info.append('学校')
|
||||
if x.market > 0:
|
||||
info.append('商场')
|
||||
if x.subway > 0:
|
||||
info.append('地铁')
|
||||
if x.bank > 0:
|
||||
info.append('银行')
|
||||
if x.hospital > 0:
|
||||
info.append('医院')
|
||||
|
||||
if 'school' in x:
|
||||
if type(x['school']) is not int:
|
||||
x.school = 0
|
||||
else:
|
||||
if x.school > 0:
|
||||
info.append('学校')
|
||||
if x.school > 10:
|
||||
x.school = 10
|
||||
if 'bank' in x:
|
||||
if type(x['bank']) is not int:
|
||||
x.bank = 0
|
||||
else:
|
||||
if x.bank > 0:
|
||||
info.append('银行')
|
||||
if x.bank > 30:
|
||||
x.bank = 30
|
||||
|
||||
if 'hospital' in x:
|
||||
if type(x['hospital']) is not int:
|
||||
x.hospital = 0
|
||||
else:
|
||||
if x.hospital > 0:
|
||||
info.append('医院')
|
||||
if x.hospital > 10:
|
||||
x.hospital = 10
|
||||
|
||||
if 'market' in x:
|
||||
if type(x['market']) is not int:
|
||||
x.market = 0
|
||||
else:
|
||||
if x.market > 0:
|
||||
info.append('商场')
|
||||
if x.market > 15:
|
||||
x.market = 15
|
||||
|
||||
if 'subway' in x:
|
||||
if type(x['subway']) is not int:
|
||||
x.subway = 0
|
||||
else:
|
||||
if x.subway > 0:
|
||||
info.append('地铁')
|
||||
if x.subway > 5:
|
||||
x.subway = 5
|
||||
|
||||
x.district_facilitys = '、'.join(info)
|
||||
return x
|
||||
|
||||
|
||||
Reference in New Issue
Block a user