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
c527f59a
Commit
c527f59a
authored
Jan 17, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi hot insert database
parent
cd4f7988
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
feature_engineering.py
tensnsorflow/feature_engineering.py
+4
-4
multi_hot.py
tensnsorflow/multi_hot.py
+1
-1
No files found.
tensnsorflow/feature_engineering.py
View file @
c527f59a
...
@@ -26,17 +26,17 @@ def get_data():
...
@@ -26,17 +26,17 @@ def get_data():
print
(
start
)
print
(
start
)
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
sql
=
"select e.y,e.z,e.stat_date,e.ucity_id,e.clevel1_id,e.ccity_name,"
\
sql
=
"select e.y,e.z,e.stat_date,e.ucity_id,e.clevel1_id,e.ccity_name,"
\
"u.device_type,u.manufacturer,u.channel,c.top,
df.level2_ids
,e.device_id,cut.time "
\
"u.device_type,u.manufacturer,u.channel,c.top,
cl.l1,cl.l2,cl.l3
,e.device_id,cut.time "
\
"from esmm_train_data e left join user_feature u on e.device_id = u.device_id "
\
"from esmm_train_data e left join user_feature u on e.device_id = u.device_id "
\
"left join cid_type_top c on e.device_id = c.device_id "
\
"left join cid_type_top c on e.device_id = c.device_id "
\
"left join
diary_feat df on e.cid_id = df.diary_
id "
\
"left join
cid_level2 cl on e.cid_id = cl.c
id "
\
"left join cid_time_cut cut on e.cid_id = cut.cid "
\
"left join cid_time_cut cut on e.cid_id = cut.cid "
\
"where e.stat_date >= '{}'"
.
format
(
start
)
"where e.stat_date >= '{}'"
.
format
(
start
)
df
=
con_sql
(
db
,
sql
)
df
=
con_sql
(
db
,
sql
)
# print(df.shape)
# print(df.shape)
df
=
df
.
rename
(
columns
=
{
0
:
"y"
,
1
:
"z"
,
2
:
"stat_date"
,
3
:
"ucity_id"
,
4
:
"clevel1_id"
,
5
:
"ccity_name"
,
df
=
df
.
rename
(
columns
=
{
0
:
"y"
,
1
:
"z"
,
2
:
"stat_date"
,
3
:
"ucity_id"
,
4
:
"clevel1_id"
,
5
:
"ccity_name"
,
6
:
"device_type"
,
7
:
"manufacturer"
,
8
:
"channel"
,
9
:
"top"
,
10
:
"l
evel2_ids
"
,
6
:
"device_type"
,
7
:
"manufacturer"
,
8
:
"channel"
,
9
:
"top"
,
10
:
"l
1"
,
11
:
"l2
"
,
1
1
:
"device_id"
,
12
:
"time"
})
1
2
:
"l3"
,
13
:
"device_id"
,
14
:
"time"
})
print
(
"esmm data ok"
)
print
(
"esmm data ok"
)
# print(df.head(2)
# print(df.head(2)
print
(
"before"
)
print
(
"before"
)
...
...
tensnsorflow/multi_hot.py
View file @
c527f59a
...
@@ -59,7 +59,7 @@ def multi():
...
@@ -59,7 +59,7 @@ def multi():
temp
=
df
.
iloc
[
i
:]
temp
=
df
.
iloc
[
i
:]
else
:
else
:
temp
=
df
.
loc
[
i
:
i
+
n
]
temp
=
df
.
loc
[
i
:
i
+
n
]
pd
.
io
.
sql
.
to_sql
(
temp
,
"cid_level2"
,
yconnect
,
schema
=
'jerry_test'
,
if_exists
=
'
replace
'
,
index
=
False
)
pd
.
io
.
sql
.
to_sql
(
temp
,
"cid_level2"
,
yconnect
,
schema
=
'jerry_test'
,
if_exists
=
'
append
'
,
index
=
False
)
print
(
"insert done"
)
print
(
"insert done"
)
...
...
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