修复人均消费bug
This commit is contained in:
@@ -94,9 +94,9 @@ def sync(city=None):
|
||||
|
||||
# 按百分位5-95筛选数据
|
||||
cities = df['city'].unique()
|
||||
for city in cities:
|
||||
df.loc[df['city'] == city, 'minPrice5'] = np.percentile(a=df[df['city'] == city]['price'], q=5, axis=0)
|
||||
df.loc[df['city'] == city, 'minPrice95'] = np.percentile(a=df[df['city'] == city]['price'], q=95, axis=0)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user