我有一个Numpy数组形式:
string localObject = comboBox5.SelectedItem.Text;
string localPollutant = comboBox4.SelectedItem.Text;
第一列是数据,第二列是第二个时间戳。数据分为两部分,间隔为40000。
我需要的是两个数据集:
40002 1511863545
40000 1511863546
156 1511863547
40005 1511863547
40003 1511863548
40008 1511863549
340 1511863550
40011 1511863550
...
和
156 1511863547
340 1511863550
...
我怎么能,
答案 0 :(得分:1)
您可以使用相当简单的测试来执行此操作:
split_data = data[:, 0] < 40000
low_data = data[split_data]
high_data = data[~split_data]
high_data[:, 0] -= 40000
data = np.array([
[40002, 1511863545],
[40000, 1511863546],
[156, 1511863547],
[40005, 1511863547],
[40003, 1511863548],
[40008, 1511863549],
[340, 1511863550],
[40011, 1511863550],
])
print(data)
split_data = data[:, 0] < 40000
low_data = data[split_data]
high_data = data[~split_data]
high_data[:, 0] -= 40000
print(split_data)
print(low_data)
print(high_data)
[[ 40002 1511863545]
[ 40000 1511863546]
[ 156 1511863547]
[ 40005 1511863547]
[ 40003 1511863548]
[ 40008 1511863549]
[ 340 1511863550]
[ 40011 1511863550]]
[False False True False False False True False]
[[ 156 1511863547]
[ 340 1511863550]]
[[ 2 1511863545]
[ 0 1511863546]
[ 5 1511863547]
[ 3 1511863548]
[ 8 1511863549]
[ 11 1511863550]]