新增城市范围圈定
This commit is contained in:
@@ -18,7 +18,7 @@ path = "/home/airflow/data/community"
|
|||||||
m_date = dateutils.iso_format()
|
m_date = dateutils.iso_format()
|
||||||
mutex = Lock()
|
mutex = Lock()
|
||||||
|
|
||||||
def find_around_seaweed(lng, lat):
|
def find_around_seaweed(city_now, lng, lat):
|
||||||
"""
|
"""
|
||||||
查找周边均价
|
查找周边均价
|
||||||
"""
|
"""
|
||||||
@@ -29,6 +29,13 @@ def find_around_seaweed(lng, lat):
|
|||||||
"query": {
|
"query": {
|
||||||
"bool": {
|
"bool": {
|
||||||
"filter": [
|
"filter": [
|
||||||
|
{
|
||||||
|
"term": {
|
||||||
|
"city": {
|
||||||
|
"value": city_now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"range": {
|
"range": {
|
||||||
"avg_price": {
|
"avg_price": {
|
||||||
@@ -72,7 +79,8 @@ def sync(city=None):
|
|||||||
lng = commutils.format_lat_lng(item['lng'])
|
lng = commutils.format_lat_lng(item['lng'])
|
||||||
lat = commutils.format_lat_lng(item['lat'])
|
lat = commutils.format_lat_lng(item['lat'])
|
||||||
if pd.notna(lng):
|
if pd.notna(lng):
|
||||||
around_seaweed_df = find_around_seaweed(lng, lat)
|
city_now = item['city']
|
||||||
|
around_seaweed_df = find_around_seaweed(city_now, lng, lat)
|
||||||
mutex.acquire(timeout=60)
|
mutex.acquire(timeout=60)
|
||||||
if len(around_seaweed_df) > 1:
|
if len(around_seaweed_df) > 1:
|
||||||
around_seaweed_df['relative_price_ranking'] = around_seaweed_df['avg_price'].rank(pct=True)
|
around_seaweed_df['relative_price_ranking'] = around_seaweed_df['avg_price'].rank(pct=True)
|
||||||
@@ -81,10 +89,13 @@ def sync(city=None):
|
|||||||
seaweed_df.loc[index, 'relative_price_ranking'] = 0.5
|
seaweed_df.loc[index, 'relative_price_ranking'] = 0.5
|
||||||
mutex.release()
|
mutex.release()
|
||||||
|
|
||||||
with ThreadPoolExecutor(max_workers=20) as pool:
|
with ThreadPoolExecutor(max_workers=30) as pool:
|
||||||
for index, item in seaweed_df.iterrows():
|
for index, item in seaweed_df.iterrows():
|
||||||
pool.submit(find_around_price_item, index, item)
|
pool.submit(find_around_price_item, index, item)
|
||||||
|
|
||||||
|
# for index, item in seaweed_df.iterrows():
|
||||||
|
# find_around_price_item(index, item)
|
||||||
|
|
||||||
actions = list()
|
actions = list()
|
||||||
count = 0
|
count = 0
|
||||||
for index, item in seaweed_df.iterrows():
|
for index, item in seaweed_df.iterrows():
|
||||||
|
|||||||
Reference in New Issue
Block a user