新增同步字段
This commit is contained in:
@@ -34,11 +34,11 @@ def calc_percentile(city=None):
|
||||
if str(i) + '%' in item['total_price']:
|
||||
if pd.notna((item['total_price'])[str(i) + '%']):
|
||||
action = {'city': city_now, 'type': 'total_price',
|
||||
'price': int((item['total_price'])[str(i) + '%'] / 10000), 'percent': i}
|
||||
'price': int((item['total_price'])[str(i) + '%']), 'percent': i}
|
||||
else:
|
||||
if pd.notna((item['total_price'])[str(i) + '.0%']):
|
||||
action = {'city': city_now, 'type': 'total_price',
|
||||
'price': int((item['total_price'])[str(i) + '.0%'] / 10000), 'percent': i}
|
||||
'price': int((item['total_price'])[str(i) + '.0%']), 'percent': i}
|
||||
percents_actions.append(action)
|
||||
for i in range(1, 101):
|
||||
if str(i) + '%' in item['avg_price']:
|
||||
@@ -59,7 +59,6 @@ def calc_percentile(city=None):
|
||||
|
||||
for city_now in cities:
|
||||
df = consumption_aim_df[consumption_aim_df['city'] == city_now].copy()
|
||||
df['total_price'] /= 10000
|
||||
for i in range(1, 101):
|
||||
if i == 1:
|
||||
df.loc[(df['avg_price'] <= percents_df[(percents_df['type'] == 'avg_price') & (percents_df['percent'] == i)].iloc[0]['price']), 'avg_price_percentile'] = 101 - i
|
||||
@@ -74,8 +73,10 @@ def calc_percentile(city=None):
|
||||
for index, item in df.iterrows():
|
||||
row = dict()
|
||||
_id = str(item["id"])
|
||||
row['total_price_percentile'] = item['total_price_percentile']
|
||||
row['avg_price_percentile'] = item['avg_price_percentile']
|
||||
if pd.notna(item['total_price_percentile']):
|
||||
row['total_price_percentile'] = int(item['total_price_percentile'])
|
||||
if pd.notna(item['avg_price_percentile']):
|
||||
row['avg_price_percentile'] = int(item['avg_price_percentile'])
|
||||
|
||||
action = {'_op_type': 'update',
|
||||
'_index': index_name,
|
||||
|
||||
Reference in New Issue
Block a user