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
1fdbee9f
Commit
1fdbee9f
authored
Jan 14, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cid_time cut
parent
4c699c04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
cid_time_cut.py
tensnsorflow/cid_time_cut.py
+57
-0
test.py
tensnsorflow/test.py
+1
-0
No files found.
tensnsorflow/cid_time_cut.py
0 → 100644
View file @
1fdbee9f
import
pandas
as
pd
import
pymysql
from
sqlalchemy
import
create_engine
def
con_sql
(
db
,
sql
):
cursor
=
db
.
cursor
()
try
:
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
df
=
pd
.
DataFrame
(
list
(
result
))
except
Exception
:
print
(
"发生异常"
,
Exception
)
df
=
pd
.
DataFrame
()
finally
:
db
.
close
()
return
df
def
cut_map
(
x
):
if
0
<
x
<=
5
:
return
2
elif
5
<
x
<=
10
:
return
3
elif
10
<
x
<=
15
:
return
4
elif
15
<
x
<=
20
:
return
5
elif
20
<
x
<=
40
:
return
6
else
:
return
7
def
cut
():
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
sql
=
"select cid_id,time from cid_time"
df
=
con_sql
(
db
,
sql
)
df
=
df
.
rename
(
columns
=
{
0
:
"cid"
,
1
:
"time"
})
print
(
df
.
shape
)
part_1
=
df
.
loc
[
df
[
"time"
]
==
0
]
part_2
=
df
.
loc
[
df
[
"time"
]
!=
0
]
part_1
[
"time"
]
=
1
part_2
[
"time"
]
=
part_2
[
"time"
]
.
map
(
cut_map
)
merge
=
part_1
.
append
(
part_2
)
print
(
merge
.
shape
)
yconnect
=
create_engine
(
'mysql+pymysql://root:3SYz54LS9#^9sBvC@10.66.157.22:4000/jerry_test?charset=utf8'
)
pd
.
io
.
sql
.
to_sql
(
merge
,
"cid_time_cut"
,
yconnect
,
schema
=
'jerry_test'
,
if_exists
=
'replace'
,
index
=
False
)
if
__name__
==
"__main__"
:
cut
()
tensnsorflow/test.py
View file @
1fdbee9f
...
...
@@ -105,6 +105,7 @@ def get_cid_time():
if
__name__
==
"__main__"
:
get_cid_time
()
pd
.
cut
()
...
...
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