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
5fefeae5
Commit
5fefeae5
authored
Feb 24, 2020
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
b654ec10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
make_data.py
make_data.py
+5
-8
No files found.
make_data.py
View file @
5fefeae5
...
@@ -93,12 +93,10 @@ def hospital():
...
@@ -93,12 +93,10 @@ def hospital():
sql
=
"select api.id,"
\
sql
=
"select api.id,"
\
"h.hospital_id,h.hospital_exposure_pv_30,h.service_exposure_pv_30,h.expert_exposure_pv_30,"
\
"h.hospital_id,h.hospital_exposure_pv_30,h.service_exposure_pv_30,h.expert_exposure_pv_30,"
\
"h.service_ctr_30,h.hospital_ctr_30,h.expert_ctr_30,"
\
"h.service_ctr_30,h.hospital_ctr_30,h.expert_ctr_30,"
\
"b.merchant_id
,budan.budan_payment_30_days
"
\
"b.merchant_id "
\
"from api_doctor api left join statistic_hospital_rank_factor h on api.hospital_id = h.hospital_id "
\
"from api_doctor api left join statistic_hospital_rank_factor h on api.hospital_id = h.hospital_id "
\
"left join hippo_merchantrelevance b on api.id = b.doctor_id "
\
"left join hippo_merchantrelevance b on api.id = b.doctor_id "
\
"left join al_meigou_service_smart_rank_budan_payment budan on b.merchant_id = budan.merchant_id "
\
"where api.doctor_type = 1 and h.date = '{}';"
.
format
(
date_str
)
"where api.doctor_type = 1 and h.date = '{}' "
\
"and budan.stat_date = '{}';"
.
format
(
date_str
,
date_tmp
)
db
=
pymysql
.
connect
(
host
=
'172.16.30.143'
,
port
=
3306
,
user
=
'work'
,
passwd
=
'BJQaT9VzDcuPBqkd'
,
db
=
'zhengxing'
)
db
=
pymysql
.
connect
(
host
=
'172.16.30.143'
,
port
=
3306
,
user
=
'work'
,
passwd
=
'BJQaT9VzDcuPBqkd'
,
db
=
'zhengxing'
)
cursor
=
db
.
cursor
()
cursor
=
db
.
cursor
()
...
@@ -106,8 +104,7 @@ def hospital():
...
@@ -106,8 +104,7 @@ def hospital():
result
=
cursor
.
fetchall
()
result
=
cursor
.
fetchall
()
df
=
pd
.
DataFrame
(
list
(
result
))
df
=
pd
.
DataFrame
(
list
(
result
))
name
=
[
"doctor_id"
,
"hospital_id"
,
"hospital_exposure_pv_30"
,
"service_exposure_pv_30"
,
name
=
[
"doctor_id"
,
"hospital_id"
,
"hospital_exposure_pv_30"
,
"service_exposure_pv_30"
,
"expert_exposure_pv_30"
,
"service_ctr_30"
,
"hospital_ctr_30"
,
"expert_ctr_30"
,
"merchant_id"
,
"expert_exposure_pv_30"
,
"service_ctr_30"
,
"hospital_ctr_30"
,
"expert_ctr_30"
,
"merchant_id"
]
"budan_payment_30_days"
]
df
=
df
.
rename
(
columns
=
dict
(
zip
(
list
(
range
(
len
(
name
))),
name
)))
df
=
df
.
rename
(
columns
=
dict
(
zip
(
list
(
range
(
len
(
name
))),
name
)))
...
@@ -130,7 +127,7 @@ def hospital():
...
@@ -130,7 +127,7 @@ def hospital():
df
=
pd
.
merge
(
df
,
tmp
,
on
=
'merchant_id'
)
df
=
pd
.
merge
(
df
,
tmp
,
on
=
'merchant_id'
)
for
i
in
[
"hospital_exposure_pv_30"
,
"service_exposure_pv_30"
,
"expert_exposure_pv_30"
,
for
i
in
[
"hospital_exposure_pv_30"
,
"service_exposure_pv_30"
,
"expert_exposure_pv_30"
,
"service_ctr_30"
,
"hospital_ctr_30"
,
"expert_ctr_30"
,
"budan_payment_30_days"
,
"service_ctr_30"
,
"hospital_ctr_30"
,
"expert_ctr_30"
,
"doctor_discount_30_days"
,
"service_pv_30"
,
"mexpert_pv_30"
,
"organization_pv_30"
,
"doctor_discount_30_days"
,
"service_pv_30"
,
"mexpert_pv_30"
,
"organization_pv_30"
,
"expand_rechange_amount_30"
]:
"expand_rechange_amount_30"
]:
df
[
i
]
=
df
[
i
]
.
astype
(
"float"
)
df
[
i
]
=
df
[
i
]
.
astype
(
"float"
)
...
@@ -163,7 +160,7 @@ def hospital():
...
@@ -163,7 +160,7 @@ def hospital():
columns
=
[
"doctor_id"
,
"score"
,
"ctr"
,
"commission"
,
"cpt"
,
"hospital_id"
,
"hospital_exposure_pv_30"
,
columns
=
[
"doctor_id"
,
"score"
,
"ctr"
,
"commission"
,
"cpt"
,
"hospital_id"
,
"hospital_exposure_pv_30"
,
"service_exposure_pv_30"
,
"expert_exposure_pv_30"
,
"service_exposure_pv_30"
,
"expert_exposure_pv_30"
,
"service_ctr_30"
,
"hospital_ctr_30"
,
"expert_ctr_30"
,
"merchant_id"
,
"budan_payment_30_days"
,
"service_ctr_30"
,
"hospital_ctr_30"
,
"expert_ctr_30"
,
"merchant_id"
,
"doctor_discount_30_days"
,
"service_pv_30"
,
"mexpert_pv_30"
,
"organization_pv_30"
,
"doctor_discount_30_days"
,
"service_pv_30"
,
"mexpert_pv_30"
,
"organization_pv_30"
,
"expand_rechange_amount_30"
]
"expand_rechange_amount_30"
]
data
=
df
.
loc
[:,
columns
]
data
=
df
.
loc
[:,
columns
]
...
...
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