Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
c099f57b
Commit
c099f57b
authored
4 years ago
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get order data
parent
d8cc9dfe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
tag3_update_user_portrait_offline.py
eda/smart_rank/tag3_update_user_portrait_offline.py
+6
-3
tool.py
eda/smart_rank/tool.py
+28
-0
No files found.
eda/smart_rank/tag3_update_user_portrait_offline.py
View file @
c099f57b
...
@@ -8,8 +8,8 @@ import pymysql
...
@@ -8,8 +8,8 @@ import pymysql
from
pyspark
import
SparkConf
from
pyspark
import
SparkConf
from
pyspark.sql
import
SparkSession
from
pyspark.sql
import
SparkSession
from
tool
import
(
get_doris_prod
,
get_redis_client
,
get_tag3_user_log
,
get_
user_portrait_tag3_with_score
,
send_email
,
from
tool
import
(
get_doris_prod
,
get_redis_client
,
get_tag3_user_log
,
get_
tag3_user_order_log
,
get_user_portrait_tag3_with_score
,
write_user_portrait
)
send_email
,
write_user_portrait
)
# [{'激光': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873, '植发际线': 7.1}]
# [{'激光': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873, '植发际线': 7.1}]
...
@@ -350,7 +350,10 @@ if __name__ == "__main__":
...
@@ -350,7 +350,10 @@ if __name__ == "__main__":
# df[["projects", "business_tags"]]
# df[["projects", "business_tags"]]
# update_tag3_user_portrait(cl_id)
# update_tag3_user_portrait(cl_id)
consume_kafka
()
cl_id
=
"867617044159377"
print
(
get_tag3_user_order_log
(
cl_id
))
# consume_kafka() TODO
end
=
datetime
.
datetime
.
now
()
end
=
datetime
.
datetime
.
now
()
print
(
end
-
start
)
print
(
end
-
start
)
print
(
"done"
)
print
(
"done"
)
This diff is collapsed.
Click to expand it.
eda/smart_rank/tool.py
View file @
c099f57b
...
@@ -442,6 +442,34 @@ def get_tag3_user_log(cl_id):
...
@@ -442,6 +442,34 @@ def get_tag3_user_log(cl_id):
return
pd
.
DataFrame
(
columns
=
columns
)
return
pd
.
DataFrame
(
columns
=
columns
)
def
1
get_tag3_user_order_log
(
cl_id
):
columns
=
[
"log_time"
,
"score_type"
,
"business_tags"
,
"event_cn"
]
try
:
sql
=
"""select log_time, score_type, business_tags, event_cn
from kafka_tag3_log
where cl_id = '{}' and event_cn in ('支付订单', '验证订单')"""
.
format
(
cl_id
)
db
,
cursor
=
get_doris_prod
()
cursor
.
execute
(
sql
)
data
=
list
(
cursor
.
fetchall
())
db
.
close
()
cursor
.
close
()
if
data
:
user_df
=
pd
.
DataFrame
(
data
)
user_df
.
columns
=
columns
else
:
return
pd
.
DataFrame
(
columns
=
columns
)
user_df
[
"days_diff_now"
]
=
round
((
int
(
time
.
time
())
-
user_df
[
"log_time"
]
.
astype
(
float
))
/
(
24
*
60
*
60
))
user_df
[
"tag_score"
]
=
user_df
.
apply
(
lambda
x
:
compute_tag3_score
(
x
),
axis
=
1
)
user_df
[
"business_tags"
]
=
user_df
[
"business_tags"
]
.
fillna
(
""
)
except
Exception
as
e
:
print
(
e
)
return
pd
.
DataFrame
(
columns
=
columns
)
# CREATE TABLE `user_tag3_portrait` (
# CREATE TABLE `user_tag3_portrait` (
# `id` int(11) NOT NULL AUTO_INCREMENT,
# `id` int(11) NOT NULL AUTO_INCREMENT,
# `date` text NOT NULL,
# `date` text NOT NULL,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment