I have a list of latitude and longitude as follows:
['33.0595Â° N', '101.0528Â° W']
I need to convert it to floats
Sure, the ‘-‘ is the only difference, but it changes when changing hemispheres, which is why a library would be ideal, but I can’t find one.
You can wrap the following code in a function and use it:
import re l = ['33.0595Â° N', '101.0528Â° W'] new_l =  for e in l: num = re.findall("d+.d+", e) if e[-1] in ["W", "S"]: new_l.append(-1. * float(num)) else: new_l.append(float(num)) print(new_l) # [33.0595, -101.0528]
The result match what you expect.