测试偏差较大案例统计数据新增 房价网均价、链家均价、贝壳均价
This commit is contained in:
@@ -3,6 +3,8 @@ import logging
|
||||
import pandas as pd
|
||||
import requests
|
||||
from goojia_utils import dateutils, pgsql
|
||||
from datetime import datetime, timedelta
|
||||
from goojia_utils import MAIN_MONGO_CLIENT
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
path = "/home/airflow/data/jh/price"
|
||||
@@ -27,7 +29,26 @@ deal_price_df = deal_df.merge(price_df, on="gujia_comm_id", how="left")
|
||||
deal_price_df["ppe"] = round((deal_price_df["gujia_comm_basic_prc"] - deal_price_df['gujia_bds_trdtckt_prc']) / deal_price_df['gujia_bds_trdtckt_prc'], 4)
|
||||
deal_price_df = deal_price_df[abs(deal_price_df['ppe']) > 0.15]
|
||||
|
||||
# third_df = pd.read_sql(f"select gujia_trdpt_avprc_id,gujia_bds_id as gujia_comm_id,gujia_dtsr_dsc,gujia_bds_comm_avprc from base.t0831_bigdata_third_party_price_gj_h where gujiabds_avprc_dt_val={month_last} ", con=engine)
|
||||
third_df = pd.read_sql(f"select gujia_bds_id as gujia_comm_id,gujia_dtsr_dsc,gujia_bds_comm_avprc from base.t0831_bigdata_third_party_price_gj_h where gujiabds_avprc_dt_val={month_last} ", con=engine)
|
||||
third_df = third_df[third_df.gujia_dtsr_dsc.isin(['贝壳','链家'])]
|
||||
# third_df = third_df[['gujia_comm_id','gujia_dtsr_dsc','gujia_bds_comm_avprc']]
|
||||
pivot_df = third_df.pivot(index='gujia_comm_id', columns='gujia_dtsr_dsc', values='gujia_bds_comm_avprc').reset_index()
|
||||
deal_price_df = pd.merge(deal_price_df, pivot_df, how='left', left_on='gujia_comm_id', right_on='gujia_comm_id')
|
||||
|
||||
# 获取上周日
|
||||
today = datetime.today()
|
||||
last_sunday = today - timedelta(days=today.weekday() + 1)
|
||||
last_sunday = last_sunday.strftime("%Y-%m-%d")
|
||||
stat = pd.DataFrame(list(MAIN_MONGO_CLIENT.get_collection("fangjia_stat", "district_stat").find({"weekend": dateutils.parse_date(last_sunday)},{"city":1,"region":1,"district_name":1,"avg_price":1,"avg_price_2b":1,"_id":0})))
|
||||
seaweed = pd.DataFrame(list(MAIN_MONGO_CLIENT.get_collection("fangjia", "seaweed").find({"status":0, "cat":"district"},{'city':1, 'region':1,'name':1,'_id':1})))
|
||||
comm_price = pd.merge(seaweed, stat, how='left', left_on=['city','region','name'], right_on=['city','region','district_name'])
|
||||
comm_price = comm_price[['_id','avg_price','avg_price_2b']]
|
||||
deal_price_df['gujia_comm_id'] = deal_price_df['gujia_comm_id'].astype('str')
|
||||
comm_price['_id'] = comm_price['_id'].astype('str')
|
||||
deal_price_df = pd.merge(deal_price_df, comm_price, how='left', left_on='gujia_comm_id', right_on='_id')
|
||||
|
||||
|
||||
|
||||
# third_price_df = third_df.merge(price_df, on="gujia_comm_id", how="left")
|
||||
# third_price_df["ppe"] = round((third_price_df["gujia_comm_basic_prc"] - third_price_df['gujia_bds_comm_avprc']) / third_price_df['gujia_bds_comm_avprc'], 4)
|
||||
# third_price_df = third_price_df[abs(third_price_df['ppe']) > 0.15]
|
||||
@@ -36,7 +57,7 @@ deal_price_df = deal_price_df[abs(deal_price_df['ppe']) > 0.15]
|
||||
file_name = f"{month_now}测试偏差较大案例统计数据.xlsx"
|
||||
aim_file_name = path + '/' + file_name
|
||||
with pd.ExcelWriter(aim_file_name) as writer:
|
||||
deal_price_df.to_excel(writer, sheet_name="成交", columns=['urbn_id','urbn_nm','gujia_bds_mdl_id','gujia_admndiv_nm','gujia_comm_id','comm_nm','gujia_bds_clmtd','gujia_comm_basic_prc','gujia_bds_trdtckt_prc','ppe'], header=["城市id", "城市名称","成交id","区域","小区id","小区名称",'计算类型','计算价格','成交价格','PPE'], index=False)
|
||||
deal_price_df.to_excel(writer, sheet_name="成交", columns=['urbn_id','urbn_nm','gujia_bds_mdl_id','gujia_admndiv_nm','gujia_comm_id','comm_nm','gujia_bds_clmtd','gujia_comm_basic_prc','gujia_bds_trdtckt_prc','ppe','贝壳','链家','avg_price','avg_price_2b'], header=["城市id", "城市名称","成交id","区域","小区id","小区名称",'计算类型','计算价格','成交价格','PPE','贝壳','链家','avg_price','avg_price_2b'], index=False)
|
||||
# third_price_df.to_excel(writer, sheet_name="第三方", columns=['urbn_id','urbn_nm','gujia_trdpt_avprc_id','gujia_admndiv_nm','gujia_comm_id','comm_nm','gujia_bds_clmtd','gujia_comm_basic_prc','gujia_bds_comm_avprc','PPE','gujia_dtsr_dsc'], header=["城市id", "城市名称","第三方id","区域","小区id","小区名称",'计算类型','计算价格','第三方价格','PPE','来源'],index=False)
|
||||
|
||||
log.info("偏差较大案例统计数据结束")
|
||||
|
||||
Reference in New Issue
Block a user