Traceback (most recent call last):
File "/Users/HectorVelasquez/PycharmProjects/Project 1/Project 1 python.py", line 57, in <module>
df['log'] = df['Latitude'].apply(lambda x: convert_rad(x))
File "/Users/HectorVelasquez/PycharmProjects/Project 1/venv/lib/python3.7/site-packages/pandas/core/series.py", line 4045, in apply
mapped = lib.map_infer(values, f, convert=convert_dtype)
File "pandas/_libs/lib.pyx", line 2228, in pandas._libs.lib.map_infer
File "/Users/HectorVelasquez/PycharmProjects/Project 1/Project 1 python.py", line 57, in <lambda>
df['log'] = df['Latitude'].apply(lambda x: convert_rad(x))
File "/Users/HectorVelasquez/PycharmProjects/Project 1/Project 1 python.py", line 7, in convert_rad
degree = int(temp[0]) + int(temp[1][:-1])/60
ValueError: invalid literal for int() with base 10: '81?36N'
текстовый файл Я не знаю, как исправить ошибку.
Широта Долгота Город Провинция / Штат Страна
81? 36N 16? 40 Вт Норд Гренландия Дания
79? 59N 85? 56 Вт Эврика Нунавут Канада
78? 55N 11? 56E Ny-? Lesund Шпицберген Норвегия
78? 13N 15? 39E Longyearbyen Svalbard Norway
функция преобразования
def convert_rad(lon):
temp = lon.split('°')
degree = int(temp[0]) + int(temp[1][:-1])/60
direction = temp[1][-1]
if direction=='N' or direction=='E':
sign = 1
elif direction=='S' or direction=='W':
sign = -1
return degree*sign*np.pi/180
Latitude_66N = convert_rad('66°0N')
Latitude_35N_66N = convert_rad('35°0N')
Latitude_35S_35N = convert_rad('35°0S')
Latitude_35S_66S = convert_rad('66°0N')
Latitude_66S = convert_rad('66°0N')
lon = convert_rad('37°22N')
lat = convert_rad('120°42W')
Изображение: линия 57