区域评级异常修复
This commit is contained in:
@@ -53,9 +53,10 @@ def process_city(args):
|
||||
if 'score' in str(col):
|
||||
region_stat[col] = region_stat[col].apply(lambda x: round(x, 2))
|
||||
region_stat['resistance_coef'] = region_stat['resistance_coef'].apply(lambda x: int(x))
|
||||
|
||||
region_stat_keys = { "city": 1, "region": 1, "avg_price": 1, "mom": 1, "yoy": 1, "_id": 0 }
|
||||
region_sell_stat = pd.DataFrame(region_sell_stat_client.find({"city": city, "date": calc_year_month}, region_stat_keys))
|
||||
if region_sell_stat.empty:
|
||||
return
|
||||
region_sell_stat['yoy'] = region_sell_stat['yoy'] * 100
|
||||
region_sell_stat['mom'] = region_sell_stat['mom'] * 100
|
||||
region_sell_stat['yoy'] = region_sell_stat['yoy'].apply(lambda x: round(x, 2))
|
||||
@@ -87,8 +88,8 @@ def process_city(args):
|
||||
updater.bulk_insert_or_update_by_id(region_stat, id_fields=['city', 'region', 'date'], dtype=dtype)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--city', type=str, default='all')
|
||||
parser.add_argument('--month', type=str, default='')
|
||||
@@ -101,7 +102,10 @@ if __name__ == '__main__':
|
||||
calc_year_months = [int(dateutils.format_date(dateutils.add_months(datetime.now(), months=-1), "%Y%m"))]
|
||||
else:
|
||||
calc_year_months = [int(calc_year_month.strip()) for calc_year_month in args.month.split(',') if calc_year_month.strip()]
|
||||
|
||||
# for city in cities:
|
||||
# args_list = [{"city": city, "calc_year_month": calc_year_month} for calc_year_month in calc_year_months]
|
||||
# for args in args_list:
|
||||
# process_city(args)
|
||||
with multiprocessing.Pool(processes=min(8, len(calc_year_months))) as pool:
|
||||
# for calc_year_month in calc_year_months:
|
||||
# args_list = [{"calc_year_month": calc_year_month, "city": city} for city in cities]
|
||||
|
||||
Reference in New Issue
Block a user