Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

window-cor.py 1.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. # 参数:时间窗长度,计算频率,最低采样数,观察阈值,故障阈值
  2. # 时间窗长度为整个dataframe,计算频率和时间窗长度在计算平台调度任务中定义
  3. import pandas as pd
  4. import numpy as np
  5. min_sample_no = 48
  6. level1 = 0.75
  7. level2 = 0.9
  8. # 数据清洗:
  9. # 1. 读入数据
  10. # 2. 去掉空值
  11. # 3. 有效采样数小于最低标准的时间窗返回空值
  12. raw = pd.read_csv('ycz6502.csv')[['time', 'zuchuan', 'value']]
  13. raw2 = pd.pivot_table(raw, values='value', index=['time'], columns=['zuchuan'])
  14. inp = raw2.dropna()
  15. inp.index = pd.to_datetime(inp.index)
  16. # 生成测试数据并校验长度
  17. test = inp.loc['2017-03-23']
  18. assert(len(test) > min_sample_no)
  19. max_current_id = test.apply(max).idxmax()
  20. cors = test.corrwith(test[max_current_id]) # or test.corr()[max_current_id]
  21. # 筛选观察组
  22. watch_grp = cors[lambda x: (x < level1) & (x > level2)]
  23. # 筛选报警组
  24. err_grp = cors[lambda x: x < level2]
  25. # 为每个组串打标签
  26. res = pd.cut(cors, bins=[0, level1, level2, 1], labels=['warn', 'watch', 'normal'])
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...