diff --git a/dags/mt/supply/data/特殊城市既无租金又无价格小区过滤.xlsx b/dags/mt/supply/data/特殊城市既无租金又无价格小区过滤.xlsx new file mode 100644 index 0000000..7f49d63 Binary files /dev/null and b/dags/mt/supply/data/特殊城市既无租金又无价格小区过滤.xlsx differ diff --git a/dags/mt/supply/rent_avg_price.py b/dags/mt/supply/rent_avg_price.py index 9ffb2e2..f70376c 100644 --- a/dags/mt/supply/rent_avg_price.py +++ b/dags/mt/supply/rent_avg_price.py @@ -7,6 +7,7 @@ import pandas as pd import datetime import logging import sys +import numpy district_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'district_stat') sqmetre_rent_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'sqmetre_rent') @@ -76,6 +77,9 @@ rent_df = rent_df[['city', 'region', 'name', 'rent_price']] result_df = pd.merge(seaweed_new_result_df, avg_df, how='left', on=['city', 'region', 'name']) result_df = pd.merge(result_df, rent_df, how='left', on=['city', 'region', 'name']) +none_rent_and_price_df = pd.read_excel('/opt/airflow/dags/repo/dags/mt/supply/data/特殊城市既无租金又无价格小区过滤.xlsx') +none_rent_and_price_cities = none_rent_and_price_df['city'].values.tolist() + def format_rent(x): """ @@ -84,8 +88,15 @@ def format_rent(x): :return: """ x.rent_price = commutils.format_rent_price(x.avg_price, x.rent_price, 1500) + # 过滤租金与均价无的小区 + if len(none_rent_and_price_cities) > 0: + if x['city'] in none_rent_and_price_cities and (np.isnan(x['rent_price']) and np.isnan(x['avg_price'])): + x['ignore_comm'] = 1 return x +result_df['ignore_comm'] = None result_df = result_df.apply(lambda x: format_rent(x), axis=1) +result_df = result_df[result_df['ignore'] != 1] + result_df.to_csv(path + '/FJW_COMM_' + output_date + '.csv', sep='@', encoding='utf-8', index=False)