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
642f63bf
Commit
642f63bf
authored
Feb 24, 2020
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
81943df7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
make_data.py
make_data.py
+14
-10
No files found.
make_data.py
View file @
642f63bf
...
...
@@ -4,8 +4,10 @@ import pandas as pd
def
doctor
():
date_str
=
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
))
.
strftime
(
"
%
Y
%
m
%
d"
)
date_tmp
=
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
))
.
strftime
(
"
%
Y-
%
m-
%
d"
)
date_str
=
"20200101"
date_tmp
=
"2020-01-01"
# date_str = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y%m%d")
# date_tmp = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
sql
=
"select d.doctor_id,d.service_exposure_pv_30,d.service_ctr_30,d.expert_exposure_pv_30,d.expert_pv_30,"
\
"b.merchant_id,budan.budan_payment_30_days "
\
...
...
@@ -56,10 +58,10 @@ def doctor():
df
[
"expert_exposure_pv_30"
]
/
df
[
"all_exposure"
]
*
(
df
[
"expert_pv_30"
]
/
df
[
"expert_exposure_pv_30"
])
df
.
loc
[
df
[
"doctor_discount_30_days"
]
<
0
,
[
"doctor_discount_30_days"
]]
=
0
df
.
loc
[
df
[
"budan_payment_30_days"
]
<
0
,
[
"budan_payment_30_days"
]]
=
0
#
df.loc[df["budan_payment_30_days"] < 0, ["budan_payment_30_days"]] = 0
df
.
loc
[
df
[
"expand_rechange_amount_30"
]
<
0
,
[
"expand_rechange_amount_30"
]]
=
0
df
[
"commission"
]
=
(
df
[
"doctor_discount_30_days"
]
+
df
[
"budan_payment_30_days"
])
/
df
[
"tmp"
]
df
[
"commission"
]
=
df
[
"doctor_discount_30_days"
]
/
df
[
"tmp"
]
df
[
"pv_ad"
]
=
df
[
"expand_rechange_amount_30"
]
/
df
[
"tmp"
]
df
.
loc
[
df
[
"all_exposure"
]
<=
1500
,
[
"ctr"
]]
=
0.01
...
...
@@ -79,13 +81,15 @@ def doctor():
data
=
df
.
loc
[:,
columns
]
data
=
data
.
drop_duplicates
()
data
.
to_csv
(
'/tmp/
6
_doctor.csv'
,
index
=
False
)
data
.
to_csv
(
'/tmp/
1
_doctor.csv'
,
index
=
False
)
print
(
"doctor end"
)
def
hospital
():
date_str
=
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
))
.
strftime
(
"
%
Y
%
m
%
d"
)
date_tmp
=
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
))
.
strftime
(
"
%
Y-
%
m-
%
d"
)
date_str
=
"20200101"
date_tmp
=
"2020-01-01"
# date_str = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y%m%d")
# date_tmp = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
sql
=
"select api.id,"
\
"h.hospital_id,h.hospital_exposure_pv_30,h.service_exposure_pv_30,h.expert_exposure_pv_30,"
\
...
...
@@ -142,10 +146,10 @@ def hospital():
df
[
"expert_exposure_pv_30"
]
/
df
[
"all_exposure"
]
*
df
[
"expert_ctr_30"
]
df
.
loc
[
df
[
"doctor_discount_30_days"
]
<
0
,
[
"doctor_discount_30_days"
]]
=
0
df
.
loc
[
df
[
"budan_payment_30_days"
]
<
0
,
[
"budan_payment_30_days"
]]
=
0
#
df.loc[df["budan_payment_30_days"] < 0, ["budan_payment_30_days"]] = 0
df
.
loc
[
df
[
"expand_rechange_amount_30"
]
<
0
,
[
"expand_rechange_amount_30"
]]
=
0
df
[
"commission"
]
=
(
df
[
"doctor_discount_30_days"
]
+
df
[
"budan_payment_30_days"
])
/
df
[
"tmp"
]
df
[
"commission"
]
=
df
[
"doctor_discount_30_days"
]
/
df
[
"tmp"
]
df
[
"cpt"
]
=
df
[
"expand_rechange_amount_30"
]
/
df
[
"tmp"
]
df
.
loc
[
df
[
"all_exposure"
]
<=
1500
,
[
"ctr"
]]
=
0.01
...
...
@@ -168,7 +172,7 @@ def hospital():
data
=
data
.
drop_duplicates
()
print
(
data
.
head
(
6
))
data
.
to_csv
(
'/tmp/
6
_hospital.csv'
,
index
=
False
)
data
.
to_csv
(
'/tmp/
1
_hospital.csv'
,
index
=
False
)
if
__name__
==
"__main__"
:
...
...
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