优化房型导出
This commit is contained in:
@@ -5,6 +5,7 @@ from goojia_utils import MAIN_MONGO_CLIENT, dateutils, commutils
|
||||
import pandas as pd
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
|
||||
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||
|
||||
@@ -37,6 +38,7 @@ def format_seaweed(x):
|
||||
"""
|
||||
try:
|
||||
if str(x.mapping_alias) != 'nan' and x.mapping_alias != None:
|
||||
# 过滤映射别名,防止含有主名
|
||||
if x.name in x.mapping_alias:
|
||||
x.mapping_alias.remove(x.name)
|
||||
x.mapping_alias = ','.join(x.mapping_alias)
|
||||
@@ -50,6 +52,25 @@ def format_seaweed(x):
|
||||
x.lng = commutils.format_lat_lng(x.lng)
|
||||
x.lat = commutils.format_lat_lng(x.lat)
|
||||
x.cubage_percent = commutils.format_plot_ratio(x.cubage_percent)
|
||||
# 过滤房型,大于5房过滤,剔除厅卫
|
||||
if 'house_type' in x and str(x['house_type']) != 'nan':
|
||||
if re.match('[1-6]室', x['house_type']) is None:
|
||||
x.house_type = None
|
||||
x.house_area = None
|
||||
else:
|
||||
x.house_type = re.sub('(\d+厅)?(\d+厨)?(\d+卫)?', '', x.house_type)
|
||||
if '1室' in x.house_type:
|
||||
if x.house_area > 125 or x.house_area < 20:
|
||||
x.house_area = None
|
||||
if '2室' in x.house_type:
|
||||
if x.house_area > 200 or x.house_area < 30:
|
||||
x.house_area = None
|
||||
if '3室' in x.house_type:
|
||||
if x.house_area > 260 or x.house_area < 60:
|
||||
x.house_area = None
|
||||
if '4室' in x.house_type:
|
||||
if x.house_area > 260 or x.house_area < 90:
|
||||
x.house_area = None
|
||||
if type(x.alias) == str and '@' in x.alias:
|
||||
x.alias = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user