优化
This commit is contained in:
+24
-16
@@ -73,7 +73,7 @@ district_facilitys_df = pd.merge(district_facilitys_df, district_facilitys_hospi
|
||||
district_facilitys_new_df = district_facilitys_df[
|
||||
['city', 'region', 'district_name', 'school', 'bank', 'hospital', 'supermarket', 'subway']]
|
||||
district_facilitys_new_df = district_facilitys_new_df.rename(columns={'district_name': 'name', 'supermarket': 'market'})
|
||||
district_facilitys_new_df = district_facilitys_new_df.drop_duplicates(subsets=['city', 'region', 'name'], keep='first')
|
||||
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')
|
||||
result_df = pd.merge(result_df, district_facilitys_new_df, how='left', on=['city', 'region', 'name'])
|
||||
@@ -83,25 +83,33 @@ result_df.loc[:, 'district_facilitys'] = None
|
||||
# 剔除特别大的
|
||||
def format_facilitys(x):
|
||||
if type(x['school']) is not int:
|
||||
x.school = None
|
||||
x.school = 0
|
||||
else:
|
||||
if x.school > 10:
|
||||
x.school = 10
|
||||
|
||||
if type(x['bank']) is not int:
|
||||
x.bank = None
|
||||
x.bank = 0
|
||||
else:
|
||||
if x.bank > 30:
|
||||
x.bank = 30
|
||||
|
||||
if type(x['hospital']) is not int:
|
||||
x.hospital = None
|
||||
x.hospital = 0
|
||||
else:
|
||||
if x.hospital > 10:
|
||||
x.hospital = 10
|
||||
if type(x['market']) is not int:
|
||||
x.market = None
|
||||
x.market = 0
|
||||
else:
|
||||
if x.market > 15:
|
||||
x.market = 15
|
||||
|
||||
if type(x['subway']) is not int:
|
||||
x.subway = None
|
||||
if x.school > 10:
|
||||
x.school = 10
|
||||
if x.market > 15:
|
||||
x.market = 15
|
||||
if x.subway > 5:
|
||||
x.subway = 5
|
||||
if x.bank > 30:
|
||||
x.bank = 30
|
||||
if x.hospital > 10:
|
||||
x.hospital = 10
|
||||
x.subway = 0
|
||||
else:
|
||||
if x.subway > 5:
|
||||
x.subway = 5
|
||||
|
||||
# 对于存在周边配套的输出字段
|
||||
info = list()
|
||||
|
||||
Reference in New Issue
Block a user