新增消费潜力评级
This commit is contained in:
@@ -3,13 +3,13 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ if type == 'all':
|
|||||||
#total_price.sync()
|
#total_price.sync()
|
||||||
#traffic.sync()
|
#traffic.sync()
|
||||||
#medical.sync()
|
#medical.sync()
|
||||||
life.sync()
|
life.sync('上海')
|
||||||
|
|||||||
@@ -3,18 +3,40 @@
|
|||||||
"""
|
"""
|
||||||
from goojia_utils import ElasticSearchClient
|
from goojia_utils import ElasticSearchClient
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
|
|
||||||
def calcConsumptionPotential():
|
def calc_consumption_potential(city):
|
||||||
"""
|
"""
|
||||||
计算消费潜力
|
计算消费潜力
|
||||||
"""
|
"""
|
||||||
|
sql = "select id, city, region, name, total_price, estate_charge, avg_price_region_ranking, avg_cost from community_summary"
|
||||||
|
if pd.notna(city):
|
||||||
|
sql += " where city=" + city
|
||||||
|
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||||
|
community_summary_df['total_price_mean'] = community_summary_df.groupby(by=['city'])['total_price'].transform(np.mean)
|
||||||
|
community_summary_df['total_price_std'] = community_summary_df.groupby(by=['city'])['total_price'].transform(np.std)
|
||||||
|
|
||||||
|
community_summary_df['estate_charge_mean'] = community_summary_df.groupby(by=['city'])['estate_charge'].transform(np.mean)
|
||||||
|
community_summary_df['estate_charge_std'] = community_summary_df.groupby(by=['city'])['estate_charge'].transform(np.std)
|
||||||
|
|
||||||
|
community_summary_df['avg_price_region_ranking_mean'] = community_summary_df.groupby(by=['city'])['avg_price_region_ranking'].transform(np.mean)
|
||||||
|
community_summary_df['avg_price_region_ranking_std'] = community_summary_df.groupby(by=['city'])['avg_price_region_ranking'].transform(np.std)
|
||||||
|
|
||||||
|
community_summary_df['avg_cost_mean'] = community_summary_df.groupby(by=['city'])['avg_cost'].transform(np.mean)
|
||||||
|
community_summary_df['avg_cost_std'] = community_summary_df.groupby(by=['city'])['avg_cost'].transform(np.std)
|
||||||
|
|
||||||
|
community_summary_df['consumption_potential'] = 286.0134196 * (community_summary_df['total_price'] - community_summary_df['total_price_avg']) / community_summary_df['total_price_std'] \
|
||||||
|
+ 139.1374524 * (community_summary_df['estate_charge'] - community_summary_df['estate_charge_avg']) / community_summary_df['estate_charge_std'] \
|
||||||
|
+ 21.8427926 * (community_summary_df['avg_price_region_ranking'] - community_summary_df['avg_price_region_ranking_avg']) / community_summary_df['avg_price_region_ranking_std'] \
|
||||||
|
+ 67.0195871700 * (community_summary_df['avg_cost'] - community_summary_df['avg_cost_mean']) / community_summary_df['avg_cost_std'] + 4099.978248
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def calcConsumptionRating():
|
|
||||||
|
def calc_consumption_rating():
|
||||||
"""
|
"""
|
||||||
计算消费等级
|
计算消费等级
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from goojia_utils import DEV_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
|
from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, commutils, dateutils, areautils, poiutils
|
||||||
from elasticsearch import helpers
|
from elasticsearch import helpers
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
seaweed_conn = DEV_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
seaweed_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||||
es206_client = ElasticSearchClient(host='192.168.0.206')
|
es206_client = ElasticSearchClient(host='192.168.0.206')
|
||||||
|
|
||||||
index_name = "community_summary"
|
index_name = "community_summary"
|
||||||
|
|||||||
Reference in New Issue
Block a user