如何计算 x 和 y 坐标与元组之间的距离

问题描述 投票:0回答:0

我想计算一个元组(此处:目标)与包含 x 和 y 坐标的两列之间的欧氏距离。我有两次 x 和 y 坐标:action 和 action1。

for action in ['action', 'action1']:
    key_start_x = '{action}_start_x'.format(action=action)
    key_start_y = '{action}_start_y'.format(action=action)
    key_start_distance = '{action}_start_distance'.format(action=action)

# Calculating the distances between shot starting point and center of opposing goal
df_shots[key_start_distance] = df_shots.apply(lambda s: distance.euclidean([key_start_x],   [key_start_y], goal), axis=1)`

我收到一条错误消息

UFuncTypeError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('<U13'), dtype('<U13')) -> None
python euclidean-distance
© www.soinside.com 2019 - 2024. All rights reserved.