Skip to main content

数据处理

[[x,y], [x,y]] 转成一维独立数组

来自chatgpt3老师

xy = [[0, 0], [480, 0], [480, 854], [0, 854]]

coordinates = np.array(xy)

x_values = coordinates[:, 0]
y_values = coordinates[:, 1]

print(x_values) # 输出:[0 480 480 0]
print(y_values) # 输出:[0 0 854 854]

合并成一个数组

import numpy as np

x = np.array([0,480,480,0])
y = np.array([0,0,854,854])

combined_array = np.column_stack((x, y))

print(combined_array)