我是靠谱客的博主 执着裙子,这篇文章主要介绍数据处理,去掉数据前后20%,然后取平均,现在分享给大家,希望可以做个参考。

复制代码
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 没有测(0,0) # 读取文件 # 排序 # 去掉首尾20% # 取平均 # 保存数据 # 绘制图像 import numpy as np import json filter_data = 'filter_data.json' def read_uwb_data(name): x = [] f = open('UWBdata/%s.txt' % name) for i in f.readlines(): a = i.strip().split(",") x.append([float(a[-3]), float(a[-2]), float(a[-1])]) return x def takeFirst(elem): return elem[0] def sort_data(x)://按照第一个元素排序 x.sort(key=takeFirst) def delete_start_end(x): delete_length = len(x) // 5 return x[delete_length:-delete_length] def get_average(x): a = np.mean(x, axis=0) return a desk_location = [{}] for i in range(26 - 6): x = read_uwb_data(i + 7) sort_data(x) x = delete_start_end(x) a = get_average(x) desk_location[0][i + 7] = [a[0], a[1]] print(desk_location) # desk_location = json.dumps(desk_location) json.dump(desk_location, open(filter_data, "w")) print(desk_location)

 

最后

以上就是执着裙子最近收集整理的关于数据处理,去掉数据前后20%,然后取平均的全部内容,更多相关数据处理内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(79)

评论列表共有 0 条评论

立即
投稿
返回
顶部