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)