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
5799b9ba
Commit
5799b9ba
authored
Jan 04, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add device_read
parent
a99d4d09
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
device_read_time_normal.py
tensnsorflow/device_read_time_normal.py
+39
-0
test.py
tensnsorflow/test.py
+16
-2
No files found.
tensnsorflow/device_read_time_normal.py
0 → 100644
View file @
5799b9ba
import
pandas
as
pd
import
pymysql
from
sklearn.preprocessing
import
MinMaxScaler
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
normal
():
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
sql
=
"select * from device_read_time"
df
=
con_sql
(
db
,
sql
)
df
=
df
.
rename
(
columns
=
{
0
:
"device_id"
,
1
:
"0"
,
2
:
"1"
,
3
:
"10"
,
4
:
"1024"
,
5
:
"1080"
,
6
:
"11"
,
7
:
"12"
,
8
:
"13"
,
9
:
"2"
,
10
:
"2054"
,
11
:
"2214"
,
12
:
"3"
,
13
:
"4"
,
14
:
"5"
,
16
:
"6933"
,
17
:
"7"
,
18
:
"9"
,
19
:
"922"
,
20
:
"929"
,
21
:
"971"
,
22
:
"992"
})
device_id
=
df
[[
"device_id"
]]
df
=
df
.
drop
(
"device_id"
,
axis
=
1
)
minMax
=
MinMaxScaler
()
result
=
minMax
.
fit_transform
(
df
)
result
=
device_id
.
join
(
result
)
yconnect
=
create_engine
(
'mysql+pymysql://root:3SYz54LS9#^9sBvC@10.66.157.22:4000/jerry_test?charset=utf8'
)
pd
.
io
.
sql
.
to_sql
(
result
,
"device_read_time_normal"
,
yconnect
,
schema
=
'jerry_test'
,
if_exists
=
'fail'
,
index
=
False
)
if
__name__
==
"__main__"
:
normal
()
\ No newline at end of file
tensnsorflow/test.py
View file @
5799b9ba
...
...
@@ -67,7 +67,7 @@ def click():
def
get_cid
():
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
sql
=
"select
distinct
cid_id from esmm_train_data where device_id = '358035085192742' "
\
sql
=
"select cid_id from esmm_train_data where device_id = '358035085192742' "
\
"and stat_date >= '2018-12-03'"
df
=
con_sql
(
db
,
sql
)[
0
]
.
values
.
tolist
()
print
(
","
.
join
(
df
))
...
...
@@ -75,6 +75,20 @@ def get_cid():
if
__name__
==
"__main__"
:
get_cid
()
import
pandas
as
pd
from
sklearn.preprocessing
import
MinMaxScaler
# 读取葡萄酒数据集
data
=
pd
.
read_csv
(
"G:/dataset/wine.csv"
)
# 获取第二列Alcohol
x
=
data
[
"Alcohol"
]
# 获取数据的基本情况
print
(
x
.
describe
())
minMax
=
MinMaxScaler
()
# 将数据进行归一化
x_std
=
minMax
.
fit_transform
(
x
)
pd
.
DataFrame
()
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