diff --git a/dags/business/business/community/avg_cost.py b/dags/business/business/community/avg_cost.py index 695422e..166f21d 100644 --- a/dags/business/business/community/avg_cost.py +++ b/dags/business/business/community/avg_cost.py @@ -54,21 +54,11 @@ def find_around_price(city_now, lng, lat): def build_doc(item): doc_dict = dict() - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print(item) - print('avg_cost' in item) if 'avg_cost' in item: - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print(item['avg_cost']) - print(pd.notna(item['avg_cost']) or item['avg_cost'] > 0) if pd.notna(item['avg_cost']) or item['avg_cost'] > 0: - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print(int(item['avg_cost'])) doc_dict['avg_cost'] = int(item['avg_cost']) else: doc_dict['avg_cost'] = None - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print(doc_dict) return doc_dict @@ -81,46 +71,16 @@ def find_around_price_item(seaweed_df, index, item): lat = commutils.format_lat_lng(item['lat']) city_now = areautils.get_city_display(item['city']) price = find_around_price(city_now, lng, lat) - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print(city_now) - print(lng) - print(lat) - print(price) - print(index) lock.acquire() if pd.notna(price): seaweed_df.loc[index, 'avg_cost'] = int(price) - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print("success") - print(seaweed_df.loc[index]) else: seaweed_df.loc[index, 'avg_cost'] = None lock.release() - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print(seaweed_df.loc[index]) def sync(city=None): log.info("开始同步消费数据...") - # 【过期,无需状态】 - # query_sql = "select id, city, tag, type, price from bd_poi where price > 0 and tag in('美食;中餐厅', '美食;外国餐厅') " - # if pd.notna(city): - # query_sql += " and city='" + areautils.get_city_display(city) + "'" - # df = es206_client.scan_by_sql_to_data_frame(query_sql) - # - # # 按百分位5-95筛选数据 - # cities = df['city'].unique() - # for city_now in cities: - # df.loc[df['city'] == city_now, 'minPrice5'] = np.percentile(a=df[df['city'] == city_now]['price'], q=5, axis=0) - # df.loc[df['city'] == city_now, 'minPrice95'] = np.percentile(a=df[df['city'] == city_now]['price'], q=95, axis=0) - # - # new_df = df[(df['price'] >= df['minPrice5']) & (df['price'] <= df['minPrice95'])] - # new_df['new_mean'] = new_df.groupby(by=['city'])['price'].transform(np.mean) - # - # # 按最新的百分位更新库中价格状态 - # update_status(new_df) - ### 人均消费大于500的,按500 - seaweed_df = pd.read_csv(path + '/seaweed.csv', sep='@', encoding='UTF-8') if pd.notna(city): seaweed_df = seaweed_df[seaweed_df['city'] == city].copy() @@ -133,9 +93,7 @@ def sync(city=None): # find_around_price_item(index, item) actions = list() count = 0 - for index, item in seaweed_df[seaweed_df['_id'] == '50bd172ae4b0fbe60a6fe628'].iterrows(): - if item['_id'] == '50bd172ae4b0fbe60a6fe628': - print(item) + for index, item in seaweed_df.iterrows(): doc_info = build_doc(item) action = {