Как применить функцию point_rotation
к столбцам Coordinates1
, Coordinates2
в приведенном ниже кадре данных:
def point_rotation(point):
"""
Changing axis
"""
xcor, ycor = (700, 0)
xcor1, ycor1 = (0, 0)
xpoint, ypoint = point
xnew = xpoint - xcor
ynew = ypoint - ycor
xnew = xcor1 + math.cos(math.radians(270)) * (xnew - xcor1) - math.sin(math.radians(90)) * (ynew - ycor1)
ynew = ycor1 + math.sin(math.radians(270)) * (xnew - xcor1) + math.cos(math.radians(90)) * (ynew - ycor1)
return round(xnew, 0), round(ynew, 0)
Вот мой текущий кадр данных:
df = pd.DataFrame({'X_1': [-34.58, -15.78, -33.45, 4.60, 10.48],
'Y_1': [-58.66, -47.91, -70.66, -74.08, -66.86],
'X_2': [-3.58, -1.8, -3.5, 4.0, 1.48],
'Y_2': [-5.66, -4.1, -7.6, -7.8, -6.86]})
df['Coordinates1'] = list(zip(df.X_1, df.Y_1))
df['Coordinates2'] = list(zip(df.X_2, df.Y_2))
Требуемый вывод: должен иметь столбцы Coordinates3
и Coordinates4
, которые в основном получены из функции point_rotation
путем передачи столбцов Coordinates1
и Coordinates2
.
Я пытался использовать функцию apply
, новыдает ошибку: too many values to unpack (expected 2)
.
Спасибо за помощь!