From 0501587af654f07d44a7f1b667fe1368c2dd2160 Mon Sep 17 00:00:00 2001 From: "shenjian@fangjia.com" Date: Tue, 10 Jan 2023 16:22:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9F=8E=E5=B8=82=E6=B6=A8?= =?UTF-8?q?=E8=B7=8C=E5=B9=85=E7=BC=BA=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/business/business/community/price.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/dags/business/business/community/price.py b/dags/business/business/community/price.py index 6cd43bb..1f26af6 100644 --- a/dags/business/business/community/price.py +++ b/dags/business/business/community/price.py @@ -72,17 +72,19 @@ def sync_by_city(city, total_seaweed_df): # 12个月均价涨跌幅 avg_price_up_and_downs_df = commutils.get_avg_price_up_and_downs(cities=[city], months=-12) - avg_price_up_and_downs_df = avg_price_up_and_downs_df[['city', 'region', 'district_name', 'up_and_downs']] - avg_price_up_and_downs_df = avg_price_up_and_downs_df.rename( - columns={'district_name': 'name', 'up_and_downs': 'year_on_year'}) - seaweed_df = pd.merge(seaweed_df, avg_price_up_and_downs_df, how='left', on=['city', 'region', 'name']) + if len(avg_price_up_and_downs_df) > 0: + avg_price_up_and_downs_df = avg_price_up_and_downs_df[['city', 'region', 'district_name', 'up_and_downs']] + avg_price_up_and_downs_df = avg_price_up_and_downs_df.rename( + columns={'district_name': 'name', 'up_and_downs': 'year_on_year'}) + seaweed_df = pd.merge(seaweed_df, avg_price_up_and_downs_df, how='left', on=['city', 'region', 'name']) # 近半年均价涨跌幅 avg_price_up_and_downs_df = commutils.get_avg_price_up_and_downs(cities=[city], months=-6) - avg_price_up_and_downs_df = avg_price_up_and_downs_df[['city', 'region', 'district_name', 'up_and_downs']] - avg_price_up_and_downs_df = avg_price_up_and_downs_df.rename( - columns={'district_name': 'name', 'up_and_downs': 'half_on_year'}) - seaweed_df = pd.merge(seaweed_df, avg_price_up_and_downs_df, how='left', on=['city', 'region', 'name']) + if len(avg_price_up_and_downs_df) > 0: + avg_price_up_and_downs_df = avg_price_up_and_downs_df[['city', 'region', 'district_name', 'up_and_downs']] + avg_price_up_and_downs_df = avg_price_up_and_downs_df.rename( + columns={'district_name': 'name', 'up_and_downs': 'half_on_year'}) + seaweed_df = pd.merge(seaweed_df, avg_price_up_and_downs_df, how='left', on=['city', 'region', 'name']) # 平米租金 rent_price_df = commutils.get_rent_price(city=city)