美团均价获取方式改变
This commit is contained in:
@@ -9,7 +9,9 @@ import logging
|
|||||||
import sys
|
import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
district_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'district_stat')
|
#district_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'district_stat')
|
||||||
|
# 月度均价表
|
||||||
|
district_sell_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'district_sell_stat')
|
||||||
sqmetre_rent_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'sqmetre_rent')
|
sqmetre_rent_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'sqmetre_rent')
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ if 'avg_price' in seaweed_new_result_df:
|
|||||||
seaweed_new_result_df = seaweed_new_result_df.drop(columns=['avg_price', 'rent_price'])
|
seaweed_new_result_df = seaweed_new_result_df.drop(columns=['avg_price', 'rent_price'])
|
||||||
|
|
||||||
month_start = dateutils.format_date(dateutils.add_months(dateutils.parse_date(output_date, '%Y%m'), months=-1), '%Y%m') + '01'
|
month_start = dateutils.format_date(dateutils.add_months(dateutils.parse_date(output_date, '%Y%m'), months=-1), '%Y%m') + '01'
|
||||||
|
year_month = month_start[0:6]
|
||||||
curr_month_start = output_date + '01'
|
curr_month_start = output_date + '01'
|
||||||
logging.info("日期信息:" + month_start + ' ' + curr_month_start)
|
logging.info("日期信息:" + month_start + ' ' + curr_month_start)
|
||||||
|
|
||||||
@@ -44,21 +47,24 @@ for index, item in threshold_df.iterrows():
|
|||||||
min_price[item['城市']] = item['均价最小值']
|
min_price[item['城市']] = item['均价最小值']
|
||||||
max_price[item['城市']] = item['均价最大值']
|
max_price[item['城市']] = item['均价最大值']
|
||||||
|
|
||||||
avg_df = pd.DataFrame()
|
# 已过期 20221108 改为从月度均价表获取【该表已控制每月涨跌幅】
|
||||||
for city in cities:
|
# avg_df = pd.DataFrame()
|
||||||
# 求当月均价均值
|
# for city in cities:
|
||||||
temp_df = pd.DataFrame(list(district_stat_conn.find(
|
# # 求当月均价均值
|
||||||
{'weekend': {'$gt': month_start_date, '$lte': curr_month_start_date}, 'city': city},
|
# temp_df = pd.DataFrame(list(district_stat_conn.find(
|
||||||
{'city': 1, 'region': 1, 'district_name': 1, 'avg_price': 1, 'weekend': 1}).batch_size(10000)))
|
# {'weekend': {'$gt': month_start_date, '$lte': curr_month_start_date}, 'city': city},
|
||||||
temp_df['avg_price_mean'] = temp_df.groupby(by=['city', 'region', 'district_name'])['avg_price'].transform('mean').astype(int)
|
# {'city': 1, 'region': 1, 'district_name': 1, 'avg_price': 1, 'weekend': 1}).batch_size(10000)))
|
||||||
temp_df = temp_df[['city', 'region', 'district_name', 'avg_price_mean']]
|
# temp_df['avg_price_mean'] = temp_df.groupby(by=['city', 'region', 'district_name'])['avg_price'].transform('mean').astype(int)
|
||||||
temp_df = temp_df.drop_duplicates(subset=['city', 'region', 'district_name'], keep='first')
|
# temp_df = temp_df[['city', 'region', 'district_name', 'avg_price_mean']]
|
||||||
# 过滤阈值
|
# temp_df = temp_df.drop_duplicates(subset=['city', 'region', 'district_name'], keep='first')
|
||||||
if city in min_price:
|
# # 过滤阈值
|
||||||
temp_df = temp_df[(temp_df['avg_price_mean'] >= min_price[city]) & (temp_df['avg_price_mean'] <= max_price[city])]
|
# if city in min_price:
|
||||||
avg_df = pd.concat([avg_df, temp_df])
|
# temp_df = temp_df[(temp_df['avg_price_mean'] >= min_price[city]) & (temp_df['avg_price_mean'] <= max_price[city])]
|
||||||
|
# avg_df = pd.concat([avg_df, temp_df])
|
||||||
|
# avg_df = avg_df.rename(columns={'district_name': 'name', 'avg_price_mean': 'avg_price'})
|
||||||
|
|
||||||
avg_df = avg_df.rename(columns={'district_name': 'name', 'avg_price_mean': 'avg_price'})
|
avg_df = pd.DataFrame(list(district_sell_conn.find({'date': int(year_month)}, {'city': 1, 'region': 1, 'district_name': 1, 'avg_price': 1}).batch_size(100000)))
|
||||||
|
avg_df = avg_df.rename(columns={'district_name': 'name'})
|
||||||
|
|
||||||
rent_df = pd.DataFrame()
|
rent_df = pd.DataFrame()
|
||||||
for city in cities:
|
for city in cities:
|
||||||
|
|||||||
Reference in New Issue
Block a user