Hi Stack Overflow community!
I have a dataframe that includes 2 columns of UTM coordinates ('X' and 'Y') as shown on the screenshot below:
I have been trying to convert and replace those 2 columns into Longitude and Latitude as shown below:
Longitude Latitude 1.601554 42.546245 53.847818 23.424076 67.709953 33.93911 ... and so on
Here's the code I usded:
def rule(row): lat, lon = utm.to_latlon(row["X"], row["Y"]) return pd.Series({"lat": lat, "long": long}) df.merge(df.apply(rule, axis=1), left_index= True, right_index= True)
FYI, to import utm, I have installed the utm 0.4.2 using Terminal.
However, it keeps giving me the following Type Error when i ran the code:
I am really new to data science and Python, so it is very difficult for me to figure out what I have done wrong.. :'(
Any helps or advice would be greatly appreciated!