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
301fbcd0
Commit
301fbcd0
authored
Oct 24, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change
parent
1b5adb17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
ctr_exp.py
ctr_exp.py
+19
-18
No files found.
ctr_exp.py
View file @
301fbcd0
...
...
@@ -11,20 +11,6 @@ def get_yesterday_date():
print
(
yesterday
)
return
yesterday
def
get_data
():
conn2db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'eagle'
)
cursor
=
conn2db
.
cursor
()
sql
=
"select distinct device_id from ffm_diary_queue_temp where device_id regexp '[5|6]$'"
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
device
=
tuple
(
pd
.
DataFrame
(
list
(
result
))[
0
]
.
values
.
tolist
())
cursor
.
close
()
print
(
device
[
0
:
2
])
return
device
def
ctr_all
():
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_prod'
)
cursor
=
db
.
cursor
()
...
...
@@ -52,9 +38,24 @@ def ctr_all():
df
.
to_csv
(
DIRECTORY_PATH
+
"exp.csv"
,
index
=
None
)
def
get_data
():
conn2db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
cursor
=
conn2db
.
cursor
()
sql
=
"select cid,exp,click from diary_ctr"
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
cursor
.
close
()
return
result
if
__name__
==
"__main__"
:
DIRECTORY_PATH
=
"/data2/ffm/"
date
=
get_yesterday_date
()
device_id
=
get_data
()
ctr_all
()
DIRECTORY_PATH
=
"/home/gmuser/"
df
=
pd
.
DataFrame
(
list
(
get_data
()))
print
(
df
.
head
())
df
=
df
.
rename
(
columns
=
{
0
:
"cid"
,
1
:
"exp"
,
2
:
"click"
})
df
[
"click"
]
=
df
[
"click"
]
.
fillna
(
0
)
df
[
"ctr"
]
=
df
[
"click"
]
/
df
[
"exp"
]
print
(
df
.
head
(
6
))
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