添加API启动支持
This commit is contained in:
@@ -164,8 +164,8 @@ def update_office(city, office, sample, year_month):
|
||||
office['estate_type2'] = None
|
||||
if 'alias' not in office.columns:
|
||||
office['alias'] = None
|
||||
if sample.empty:
|
||||
return
|
||||
merge_df = None
|
||||
if not sample.empty:
|
||||
sample_new = sample
|
||||
if 'alias' not in sample_new.columns:
|
||||
sample_new['alias'] = None
|
||||
@@ -221,6 +221,8 @@ def update_office(city, office, sample, year_month):
|
||||
# 第二步 取周边3公里内同等级、同类型的最近10个有样本写字楼的基准价的平均值
|
||||
office_info = office[['city', 'region', 'name', 'lng', 'lat', 'estate_type2', 'bed_kind']].drop_duplicates(
|
||||
keep='first')
|
||||
combined = office_info
|
||||
if merge_df is not None and not merge_df.empty:
|
||||
combined = pd.concat([office_info, merge_df])
|
||||
diff_df = combined.drop_duplicates(subset=['city', 'region', 'name'], keep=False)
|
||||
actions = list()
|
||||
@@ -464,7 +466,7 @@ def getOffice(city, district=None, name=None):
|
||||
query['city'] = city
|
||||
if pd.notna(district):
|
||||
query['region'] = district
|
||||
if pd.notna(city):
|
||||
if pd.notna(name):
|
||||
query['name'] = name
|
||||
office = pd.DataFrame(list(seaweed_df.find(query).batch_size(10000)))
|
||||
for col in ['city', 'region', 'name', 'alias', 'estate_type2', 'bed_kind', 'lng', 'lat']:
|
||||
@@ -477,4 +479,4 @@ def getOffice(city, district=None, name=None):
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 测试脚本:直接运行时模拟 Airflow 的上下文
|
||||
calc(dag_run=type('DagRun', (), {'conf': {'city': '上海', 'district': '静安', 'name': '凯迪克大厦'}}))
|
||||
calc(dag_run=type('DagRun', (), {'conf': {'city': '西安'}}))
|
||||
Reference in New Issue
Block a user