Commit 6960865b authored by 桂秋月's avatar 桂秋月

新增推荐脚本

parent efb0d705
......@@ -16,6 +16,7 @@ mysql_info={
"host":"172.24.17.119",
"port":"15307"
},
"220":{
"name":"recommender_user_rw",
"pwd":"rkwnPEG4",
......@@ -51,6 +52,13 @@ mysql_info={
"pwd":"3^4f=GZeA$",
"host":"recommend-nearline-prod-5-7.cr22rydq7l0o.rds.cn-north-1.amazonaws.com.cn",
"port":"3306"
},
"usergroup":{
"name":"tjzimuali_test",
"pwd":"bYut032QgkJ7ElMXwW",
"host":"aliyun-test.mongodb.rds.aliyuncs.com:3717,dds-2ze3634f3b850e642.mongodb.rds.aliyuncs.com",
"port":"3717"
# mongodb://tjzimuali_test:bYut032QgkJ7ElMXwW@aliyun-test.mongodb.rds.aliyuncs.com:3717,dds-2ze3634f3b850e642.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-58488296
}
}
......
......@@ -9,14 +9,22 @@ def mongo_universal(namespace):
print("mongodb连接信息:",temp)
return temp
def mongoClient(namespace,db="app_vcc2"):
def personmongoClient(namespace,db="app_vcc2"):
'''
:param namespace:
:param db:
:return: 自动连接该db
'''
#mongo_info=mysqlInfo(namespace,dbtype='mongodb')
temp=mongo_universal(namespace)
return eval("MongoClient(temp).{db}".format(db=db))
#temp_db=eval("MongoClient(temp)")# .format(db=db))
temp_db=eval("MongoClient(temp).{db}".format(db=db))
try:
#if temp_db.authenticate(mongo_info.get('name'),mongo_info.get('pwd')):
return temp_db
except:
print('moongo连接失败',type(temp_db))
traceback.print_exc(2)
def tableSearch(namespace,tablename,**kwargs):
'''
......@@ -27,7 +35,7 @@ def tableSearch(namespace,tablename,**kwargs):
:return: 返回find结果
'''
temp=''
db=mongoClient(namespace,kwargs.get('db'))
db=personmongoClient(namespace,kwargs.get('db'))
tables=[i['name'] for i in db.list_collections()]
if tablename not in tables:
raise Exception('table[{}]不在databse[{}]中,所有的table如下:'.format(tablename,kwargs.get('db')),tables)
......@@ -43,12 +51,13 @@ def tableSearch(namespace,tablename,**kwargs):
if __name__ == '__main__':
key={"db":"ocrDb","query":[{
#,"userId":"70549608"
},{"_id":1}]}
temp=tableSearch('qa','system.version',**key)
result=[i for i in temp]
print(len(result))
for i in temp:
print('===',i)
print(temp)
\ No newline at end of file
# key={"db":"ocrDb","query":[{
# #,"userId":"70549608"
# },{"_id":1}]}
# temp=tableSearch('usergroup','ocrVerifyBaseInfo',**key)
# result=[i for i in temp]
# print(len(result))
# for i in temp:
# print('===',i)
# print(temp)
print(personmongoClient('usergroup'))
......@@ -72,4 +72,5 @@ def concatSql(sql,**kwargs):
return sql+' where '+temp[:-4]
if __name__ == '__main__':
print(execmysl('qa',"select sku_name from kdsp.t_sku_info where sku_name like '%%口红%%'"))
\ No newline at end of file
print(mysqlInfo('test1'))
#print(execmysl('qa',"select sku_name from kdsp.t_sku_info where sku_name like '%%口红%%'"))
\ No newline at end of file
......@@ -54,7 +54,7 @@ def getRedisValue(key,conntype=None,oper='select'):
redis_db_conn=dapan_redis_db_conn
else:
redis_db_conn=redis_db_conn_119
uuid_redis_result=redis_db_conn.keys(key)
uuid_redis_result=redis_db_conn.keys(key.strip())
print('模糊匹配到的所有key:',uuid_redis_result)
if uuid_redis_result and oper=='delete':
for i in uuid_redis_result:
......@@ -68,7 +68,7 @@ def getRedisValue(key,conntype=None,oper='select'):
for i in uuid_redis_result:
redis_key_type=redis_db_conn.type(i)
if redis_key_type == 'list':
redis_value[i]=redis_db_conn.lrange(i,0,100)
redis_value[i]=redis_db_conn.lrange(i,0,300)
# uuid_redis_result = redis_db_conn.lrange(i)
elif redis_key_type in ('dict','hash'):
redis_value[i]=redis_db_conn.hgetall(i)
......@@ -84,7 +84,8 @@ def getRedisValue(key,conntype=None,oper='select'):
if __name__ == '__main__':
userUuid='00003a93-2a32-4501-b338-755b6cb1ec49'
t=getRedisValue("same_product_batch_uuid")
#t=getRedisValue("order_product_graph:179240378044417")
t=getRedisValue("pay_product_graph:179240378044417")
print(t)
## search_fm_offline_feature:{md5(搜索词)}_query_offline
......
from recommend import *
def appTopic():
temp=defaultdict(list)
cid3_cate_brand_heat_rank_change_sql=cate_brand_heat_rank_sql+' where show_type=1 order by rank asc limit 30'
brandname_cate_brand_heat_rank_change_sql=cate_brand_heat_rank_sql+' where show_type=2 order by rank asc limit 30'
cid3_df=execmysl(119,cid3_cate_brand_heat_rank_change_sql)
brandname_df=execmysl(119,brandname_cate_brand_heat_rank_change_sql)
temp['apptopic_cid3']=cid3_df['show_id'].to_list() if not cid3_df.empty else []
temp['apptopic_brandname']=cid3_df['show_id'].to_list() if not cid3_df.empty else []
return temp
def clickTopic(skuno,cid3=None,brandid=None):
temp=defaultdict()
from recommend.publicFunc import skuinfo
sku_infos=skuinfo(skuno)
if cid3 and brandid:
sku_infos['cid3']=cid3
sku_infos['brand_id']=brandid
cid3_intention_change_sql=concatSql(cate_brand_intention_score_sql,
**{"show_id":[sku_infos.get('cid3'),sku_infos.get('cid2'),sku_infos.get('cid1')]})
cid3_intention_change_sql+=" or brand_id='{}'".format(sku_infos.get('brand_id'))
print('cicktopic 转换后的sql:',cid3_intention_change_sql)
cid3brandname_df=execmysl(119,cid3_intention_change_sql)#.sort_values(by=['rank'])['']
print('cicktopic的结果:',cid3brandname_df.head(1))
##cid3+brandid
temp['clicktopic_cid3']=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid2+brandid
temp['clicktopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid2'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid1+brandid
temp['clicktopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid1'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid3+无名品牌分
temp['clicktopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid2+无名品牌分
temp['clicktopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid2'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid1+无名品牌分
temp['clicktopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid1'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##无品类分+品牌分
temp['clicktopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==-1)
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['clicktopic_cid3']=removeRepeat(temp['clicktopic_cid3'])[:30]
##cid3+brandid
temp['clicktopic_brandname']=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid2+brandid
temp['clicktopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid2'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid1+brandid
temp['clicktopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid1'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid3+无名品牌分
temp['clicktopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid2+无名品牌分
temp['clicktopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid2'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##cid1+无名品牌分
temp['clicktopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid1'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
##无品类分+品牌分
temp['clicktopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==-1)
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['show_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['clicktopic_brandname']=removeRepeat(temp['clicktopic_brandname'])[:30]
return temp
def searchTopic():
temp=defaultdict(list)
from recommend.searchTopic import getseed,step1
top10_sku,_=step1()
sku_infos=getseed(top10_sku)
cid3_intention_change_sql=concatSql(cate_brand_intention_score_sql,
**{"show_id":sku_infos.get('cid3')})
cid3_intention_change_sql+=" or brand_id='{}'".format(sku_infos.get('brand_id'))
cid3brandname_df=execmysl(119,cid3_intention_change_sql)
temp['searchtopic_cid3']=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['searchtopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['searchtopic_cid3']+=cid3brandname_df[(cid3brandname_df['show_id']==-1)
& (cid3brandname_df['show_type']==1) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['searchtopic_brandname']=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['searchtopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==sku_infos.get('cid3'))
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==-1)] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['searchtopic_brandname']+=cid3brandname_df[(cid3brandname_df['show_id']==-1)
& (cid3brandname_df['show_type']==2) &(cid3brandname_df['brand_id']==sku_infos.get('brand_id'))] \
.sort_values(by=['rank'])['show_id'].to_list()[:30] if not cid3brandname_df.empty else []
temp['searchtopic_cid3']=removeRepeat(temp['searchtopic_cid3'])[:30]
temp['searchtopic_brandname']=removeRepeat(temp['searchtopic_brandname'])[:30]
return temp
if __name__ == '__main__':
print(clickTopic('179240378044417'))
from recommend import *
def dealData(t):
print('处理成json的数据:',t)
tt=json.loads(t)
temp=[]
for i in tt:
temp.append(i.get('sku_id'))
return temp
def payRecall(skuno,num=100):
temp=defaultdict(list)
print("支付图关联表召回start")
pay_product_change_redis=pay_product_redis.strip().format(sku_no=skuno)
#print(pay_product_change_redis)
pay_result=getRedisValue(pay_product_change_redis)
from recommend.publicFunc import skuinfo
skuno_info=skuinfo(skuno)
pay_skus=dealData(pay_result.get(pay_product_change_redis))
if pay_result :
skuss_change_sql=concatSql(skuinfo_sql,**{"sku_no":pay_skus}) +" and cid3!='{}'".format(skuno_info.get('cid3'))
skdss=execmysl('nearly',skuss_change_sql)
if not skdss.empty :
final_skus=skdss['sku_no'].to_list()
temp['70011']=final_skus[:num]
print("支付图关联表召回stop",len(final_skus),skuss_change_sql)
#return temp
print("下单图关联表召回start",'**'*50)
order_product_change_redis=order_product_redis.format(sku_no=skuno).strip()
order_result=getRedisValue(order_product_change_redis)
order_skus=dealData(order_result.get(order_product_change_redis))
if order_result :
skuss_change_sql=concatSql(skuinfo_sql,**{"sku_no":order_skus}) +' and cid3!={}'.format(skuno_info.get('cid3'))
skdss=execmysl('nearly',skuss_change_sql)
if not skdss.empty :
final_skus=skdss['sku_no'].to_list()
chaji=subtraction(final_skus,temp.get('70011'))
temp['70012']=chaji[:num]
print("下单图关联表召回stop",len(final_skus),skuss_change_sql)
#return temp
print("加购图关联表召回start",'**'*50)
product_change_redis=product_redis.format(sku_no=skuno).strip()
product_result=getRedisValue(product_change_redis)
if product_result :#and len(product_result.get(product_change_redis))>=num:
skuss_change_sql=concatSql(skuinfo_sql,**{"sku_no":product_result.get(product_change_redis)}) +' and cid3!={}'.format(skuno_info.get('cid3'))
skdss=execmysl('nearly',skuss_change_sql)
if not skdss.empty :#and skdss.shape>num:
final_skus=skdss['sku_no'].to_list()
chaji=subtraction(subtraction(final_skus,temp.get('70011')),temp.get('70012'))
temp['70013']=chaji
print("加购图关联表召回stop")
return temp
print("ALS相关表召回start",'**'*50)
als_correlation_change_redis=als_correlation_redis.format(sku_no=skuno).strip()
als_correlation_result=getRedisValue(als_correlation_change_redis)
if als_correlation_result :#and len(als_correlation_result.get(als_correlation_change_redis))>=num:
skuss_change_sql=concatSql(skuinfo_sql,**{"sku_no":als_correlation_result.get(als_correlation_change_redis)}) +' and cid3!={}'.format(skuno_info.get('cid3'))
skdss=execmysl('nearly',skuss_change_sql)
if not skdss.empty: #and skdss.shape>num:
final_skus=skdss['sku_no'].to_list()
chaji=subtraction(subtraction(subtraction(final_skus,temp.get('70011')),temp.get('70012')),temp.get('70013'))
temp['70014']=chaji
print("ALS相关表召回stop",len(skdss),skuss_change_sql)
#return temp
dapan_change_sql=concatSql(dapan_sql,**{"cid3":skuno_info.get('cid3')})+" and brand_name!='{}'".format(skuno_info.get('brand_name'))
dapan_df=execmysl('nearly',dapan_change_sql)
#if dapan_df.shape[0]>=50:
temp['70015_1']=dapan_df['sku_no'].to_list()[:50]
#return temp
dapan_change_sql=concatSql(dapan_sql,**{"brand_name":skuno_info.get('brand_name')})+' and cid3!={}'.format(skuno_info.get('cid3'))
dapan_df=execmysl('nearly',dapan_change_sql)
temp['70015_2']=dapan_df['sku_no'].to_list()[:50]
return temp
def backRecall(uuid):
back_recall_change_sql=nearly_batch_sql.format(uuid)+' and recall_reason!=50000'
back_recall_result=execmysl('nearly',back_recall_change_sql)
return {"7002":back_recall_result['sku_no'].to_list()} if not back_recall_result.empty else {"7002":[]}
def payDapanbu(skuno):
try:
from recommend.publicFunc import dapanBu
dapan_result=dapanBu()
return {"7003":dapan_result[:300]}
except :
traceback.print_exc(2)
return {"7003":[]}
def all(skuno,uuid):
temp=defaultdict()
sku_temp=[]
#back_recall_skus=backRecall(uuid)
#temp.append(back_recall_skus)
pay_recall_skus=payRecall(skuno,num=100)
temp.update(pay_recall_skus)
dapan_result=payDapanbu(skuno)
for k,v in temp.items():
sku_temp+=v
print('支付召回数据',sku_temp[:300])
if len(removeRepeat(mergelist(sku_temp)))<300:
temp.update(dapan_result)
return temp
def breakUp(temp):
pass
def checkresult():
a=['100012355342', '11050632353793', '11102968880129', '179229279393281', '188701955858944', '214857903777280', '214864564329984', '216227226849793', '219236606151681', '219717743418368', '219717760191488', '220405299154944', '221238765822976', '221242506611712', '221326317721601', '226455405730817', '2302639605249', '230741925957633', '232141556812289', '238057538721280', '239217926999553', '241458842967559', '241462055803909', '2428586170369', '243851634153473', '244342367719425', '245090111202307', '246531249415169', '246532608630785', '246615437743105', '257383818600960', '257401358391296', '261007085148162', '266081478647298', '275001899225600', '279850356055553', '281430559826433', '281529478289409', '282035714270724', '29169639759873', '298224007783425', '298225467657729', '301741544312332', '302492895152129', '307494551820801', '307565317857793', '311153452910081', '316840577339904', '316975868289025', '319861666615296', '320721197213185', '322042655152128', '322740226627585', '326397760381953', '328040374869504', '328575677900289', '340438528036359', '340913373319168', '340970164461576', '343082273351169', '343204705611264', '343222237008385', '343594322895873', '343989417936385', '346650937922049', '346845511949325', '346848867125256', '346936259644929', '349035157262337', '351699319917057', '351737404724737', '351824041478657', '353012455837185', '353229235030529', '355068805384705', '356766476148225', '356795642291201', '359044015728131', '361900941516801', '361913264637441', '367038149960712', '367681053661185', '369193007195649', '369201421750785', '371346178315265', '372730534042113', '372781200972325', '373380391116801', '374333605684738', '374340064647694', '377681608183297', '377843289688065', '37992240793601', '37993935289345', '383811482819591', '64833806673409', '794422', '384196679049746', '393791694966273']
sql="""
select -- a.*,
distinct b.sku_no,
b.recall_reason
-- count(1)
from
(select id,recall_batch_uuid,event_type from nearline_recommend_test.recommend_product_batch
where user_uuid='1e51cf78-e12c-4f17-9d5b-b25404303a66-3' order by id desc limit 1)a
join nearline_recommend_test.recommend_product_record b on a.recall_batch_uuid=b.recall_batch_uuid
where -- b.sku_no='37993381637121'
recall_reason=70011
"""
df=execmysl('nearly',sql)['sku_no'].to_list()
print(subtraction(a,df))
if __name__ == '__main__':
skuno='179240378044417'
uuid='1e51cf78-e12c-4f17-9d5b-b25404303a66-5'
t=all(skuno,uuid)
print(t)
#print(payDapanbu(skuno))
#print(deal_all())
#print(checkresult())
......@@ -42,7 +42,7 @@ def minPriceFill(skus,num=100):
def skuinfo(sku):
change_sql=concatSql(skuinfo_sql,**{"sku_no":sku})
sku_df=execmysl(119,change_sql)
sku_info=sku_df[['cid1','cid2','cid3','brand_name']].to_dict(orient='records')[0]
sku_info=sku_df[['cid1','cid2','cid3','brand_name','brand_id']].to_dict(orient='records')[0]
return sku_info
......
......@@ -14,11 +14,11 @@ similar_redis='product_similarity:{skuno}'
##商品关联度
correlation_redis='product_correlation:${skuNo}'
##本批次+上一批次
##上一批次
nearly_batch_sql="""
select a.*,b.sku_no,b.recall_reason from
(select id,recall_batch_uuid,event_type from nearline_recommend.recommend_product_batch where user_uuid='{}' order by id desc limit 2)a
join nearline_recommend.recommend_product_record b on a.recall_batch_uuid=b.recall_batch_uuid
(select id,recall_batch_uuid,event_type from nearline_recommend_test.recommend_product_batch where user_uuid='{}' order by id desc limit 1)a
join nearline_recommend_test.recommend_product_record b on a.recall_batch_uuid=b.recall_batch_uuid
"""
cur_batch_sql="""
......@@ -77,3 +77,30 @@ xyqb_recommender_system.kdsp_same_ranked_list
back_batch_redis="""
recommend_recall:{uuid}:{sku_no}
"""
##支付图关联表,有序列表
pay_product_redis="""pay_product_graph:{sku_no}"""
##下单图关联表,有序列表
order_product_redis="""
order_product_graph:{sku_no}
"""
##加购图关联表,字符串
product_redis="""
product_graph:{sku_no}
"""
##ALS关联度表,有序列表
als_correlation_redis="""
product_correlation:{sku_no}
"""
###more-热度表(大盘热度表)
cate_brand_heat_rank_sql="""
select * from
offline_recommend.cate_brand_heat_rank
"""
###more-用户意图得分表
cate_brand_intention_score_sql="""
select * from
offline_recommend.cate_brand_intention_score
"""
......@@ -23,8 +23,10 @@ def getseed(top10_sku):
df['cid3']=df['cid3'].astype('string')
cid3=df.groupby(by=['cid3']).groups.__repr__()#['cid3']#.max()
brandname=df.groupby(by=['brand_name']).groups.__repr__()
brandid=df.groupby(by=['brand_id']).groups.__repr__()
result['cid3']=maxdict(**json.loads(cid3.replace("'",'"')))
result['brand_name']=maxdict(**json.loads(brandname.replace("'",'"')))
result['brand_id']=maxdict(**json.loads(brandid.replace("'",'"')))
result['avg_price']=df['price'].mean()
result['skuinfo']=df.to_dict(orient='records')
return result
......
......@@ -27,6 +27,12 @@ def removeRepeat(a):
temp.sort(key=a.index)
return temp
def subtraction(a,b):
if a and b:
return list(set(a).difference(set(b)))
return b if b else a
def mergelist(a):
'''
:param a:list
......@@ -52,7 +58,19 @@ def listGroup(tt,size=3):
break
return temp
def listSubgroup(tt,size=6):
temp=[]
for i in range(0,len(tt),size):
print(tt[i:i+size])
temp.append(tt[i:i+size])
return temp
if __name__ == '__main__':
a=[1,2,4,3,5,6,7,8]
print(listGroup(a))
#print(listGroup(a))
#a=[[1,2],[2,3]]
#print(mergelist(a))
print(listSubgroup(a,6))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment