In [1]:
import pandas as pd
import numpy as np
from collections import defaultdict
from datetime import datetime
from sqlalchemy import create_engine
import matplotlib.pyplot as plt
np.random.seed(1445)
ZERO_TIMESTAMP = datetime(2017, 7, 25, 21)
class MySQLConfig:
HOST = "10.0.149.62"
USER = "root"
PASS = "root123"
DB = "hangzhouhubqa_v3"
CHARSET = 'utf8'
engine = create_engine(
f'mysql+pymysql://{USER}:{PASS}@{HOST}/{DB}?charset={CHARSET}',
isolation_level="READ UNCOMMITTED")
def load_from_mysql(table_name: str):
"""读取远程mysql数据表"""
table = pd.read_sql_table(con=MySQLConfig.engine, table_name=f"{table_name}")
return table
In [3]:
# =========================================设备输出表 o_machine_table==================================
equipment_o_t = load_from_mysql('o_machine_table')
equipment_o_t
Out[3]:
equipment_id
parcel_id
small_id
parcel_type
time_stamp
action
real_time_stamp
run_time
0
r1_2
928041
928041
parcel
1789267.00
wait
2017-08-15 14:01:07
2017-08-30 10:35:57
1
r1_2
928041
928041
parcel
1814400.00
start
2017-08-15 21:00:00
2017-08-30 10:35:57
2
r1_2
928041
928041
parcel
1814403.68
end
2017-08-15 21:00:03
2017-08-30 10:35:57
3
m1_1
928041
928041
parcel
1814445.05
wait
2017-08-15 21:00:45
2017-08-30 10:35:57
4
m1_1
928041
928041
parcel
1814445.05
start
2017-08-15 21:00:45
2017-08-30 10:35:57
5
m1_1
928041
928041
parcel
1814447.05
end
2017-08-15 21:00:47
2017-08-30 10:35:57
6
i2_3
928041
928041
parcel
1814593.59
wait
2017-08-15 21:03:13
2017-08-30 10:35:57
7
i2_3
928041
928041
parcel
1814593.59
start
2017-08-15 21:03:13
2017-08-30 10:35:57
8
i2_3
928041
928041
parcel
1814593.91
end
2017-08-15 21:03:13
2017-08-30 10:35:57
9
i1_1
928041
928041
parcel
1814734.84
wait
2017-08-15 21:05:34
2017-08-30 10:35:57
10
i1_1
928041
928041
parcel
1814734.84
start
2017-08-15 21:05:34
2017-08-30 10:35:57
11
i1_1
928041
928041
parcel
1814735.16
end
2017-08-15 21:05:35
2017-08-30 10:35:57
12
c1_33
928041
928041
parcel
1814762.00
wait
2017-08-15 21:06:02
2017-08-30 10:35:57
13
r1_4
846215
846215
parcel
1791563.00
wait
2017-08-15 14:39:23
2017-08-30 10:35:57
14
r1_4
846215
846215
parcel
1814400.00
start
2017-08-15 21:00:00
2017-08-30 10:35:57
15
r1_4
846215
846215
parcel
1814403.68
end
2017-08-15 21:00:03
2017-08-30 10:35:57
16
m1_3
846215
846215
parcel
1814445.05
wait
2017-08-15 21:00:45
2017-08-30 10:35:57
17
m1_3
846215
846215
parcel
1814445.05
start
2017-08-15 21:00:45
2017-08-30 10:35:57
18
m1_3
846215
846215
parcel
1814447.05
end
2017-08-15 21:00:47
2017-08-30 10:35:57
19
i2_3
846215
846215
parcel
1814593.59
wait
2017-08-15 21:03:13
2017-08-30 10:35:57
20
i2_3
846215
846215
parcel
1814593.59
start
2017-08-15 21:03:13
2017-08-30 10:35:57
21
i2_3
846215
846215
parcel
1814593.91
end
2017-08-15 21:03:13
2017-08-30 10:35:57
22
i1_1
846215
846215
parcel
1814734.84
wait
2017-08-15 21:05:34
2017-08-30 10:35:57
23
i1_1
846215
846215
parcel
1814734.84
start
2017-08-15 21:05:34
2017-08-30 10:35:57
24
i1_1
846215
846215
parcel
1814735.16
end
2017-08-15 21:05:35
2017-08-30 10:35:57
25
c1_33
846215
846215
parcel
1814762.00
wait
2017-08-15 21:06:02
2017-08-30 10:35:57
26
r2_1
885195
885195
parcel
1791584.00
wait
2017-08-15 14:39:44
2017-08-30 10:35:57
27
r2_1
885195
885195
parcel
1814400.00
start
2017-08-15 21:00:00
2017-08-30 10:35:57
28
r2_1
885195
885195
parcel
1814403.68
end
2017-08-15 21:00:03
2017-08-30 10:35:57
29
m1_2
885195
885195
parcel
1814445.94
wait
2017-08-15 21:00:45
2017-08-30 10:35:57
...
...
...
...
...
...
...
...
...
73
i2_2
934268
934268
parcel
1814596.80
end
2017-08-15 21:03:16
2017-08-30 10:35:57
74
i1_2
934268
934268
parcel
1814737.73
wait
2017-08-15 21:05:37
2017-08-30 10:35:57
75
i1_2
934268
934268
parcel
1814737.73
start
2017-08-15 21:05:37
2017-08-30 10:35:57
76
i1_2
934268
934268
parcel
1814738.05
end
2017-08-15 21:05:38
2017-08-30 10:35:57
77
c1_33
934268
934268
parcel
1814764.89
wait
2017-08-15 21:06:04
2017-08-30 10:35:57
78
r1_3
858865
858865
parcel
1791280.00
wait
2017-08-15 14:34:40
2017-08-30 10:35:57
79
r1_3
858865
858865
parcel
1814400.00
start
2017-08-15 21:00:00
2017-08-30 10:35:57
80
r1_3
858865
858865
parcel
1814403.68
end
2017-08-15 21:00:03
2017-08-30 10:35:57
81
m1_3
858865
858865
parcel
1814445.05
wait
2017-08-15 21:00:45
2017-08-30 10:35:57
82
m1_3
858865
858865
parcel
1814445.05
start
2017-08-15 21:00:45
2017-08-30 10:35:57
83
m1_3
858865
858865
parcel
1814447.05
end
2017-08-15 21:00:47
2017-08-30 10:35:57
84
i2_3
858865
858865
parcel
1814593.59
wait
2017-08-15 21:03:13
2017-08-30 10:35:57
85
i2_3
858865
858865
parcel
1814593.59
start
2017-08-15 21:03:13
2017-08-30 10:35:57
86
i2_3
858865
858865
parcel
1814593.91
end
2017-08-15 21:03:13
2017-08-30 10:35:57
87
e1_1
858865
858865
parcel
1815069.91
wait
2017-08-15 21:11:09
2017-08-30 10:35:57
88
e1_1
858865
858865
parcel
1815069.91
start
2017-08-15 21:11:09
2017-08-30 10:35:57
89
e1_1
858865
858865
parcel
1815069.91
end
2017-08-15 21:11:09
2017-08-30 10:35:57
90
h1_1
858865
858865
parcel
1815118.54
wait
2017-08-15 21:11:58
2017-08-30 10:35:57
91
h1_1
858865
858865
parcel
1815118.54
start
2017-08-15 21:11:58
2017-08-30 10:35:57
92
h1_1
858865
858865
parcel
1815133.54
end
2017-08-15 21:12:13
2017-08-30 10:35:57
93
x8_1
858865
858865
parcel
1815209.46
wait
2017-08-15 21:13:29
2017-08-30 10:35:57
94
x8_1
858865
858865
parcel
1815209.46
start
2017-08-15 21:13:29
2017-08-30 10:35:57
95
x8_1
858865
858865
parcel
1815209.46
end
2017-08-15 21:13:29
2017-08-30 10:35:57
96
x1_1
858865
858865
parcel
1815259.76
wait
2017-08-15 21:14:19
2017-08-30 10:35:57
97
x1_1
858865
858865
parcel
1815259.76
start
2017-08-15 21:14:19
2017-08-30 10:35:57
98
x1_1
858865
858865
parcel
1815259.76
end
2017-08-15 21:14:19
2017-08-30 10:35:57
99
i4_1
858865
858865
parcel
1815286.32
wait
2017-08-15 21:14:46
2017-08-30 10:35:57
100
i4_1
858865
858865
parcel
1815286.32
start
2017-08-15 21:14:46
2017-08-30 10:35:57
101
i4_1
858865
858865
parcel
1815286.64
end
2017-08-15 21:14:46
2017-08-30 10:35:57
102
c1_33
858865
858865
parcel
1815324.68
wait
2017-08-15 21:15:24
2017-08-30 10:35:57
103 rows × 8 columns
Content source: kissf-lu/jupyter_app
Similar notebooks: