I have a pandas data frame with columns Longitude and Latitude. I'd like to get X and Y from them. There is a function in utm called from_latlon that does this. It receives Latitude and Longitude and gives [X,Y]. Here's what I do:
def get_X(row):
return utm.from_latlon(row['Latitude'], row['Longitude'])[0]
def get_Y(row):
return utm.from_latlon(row['Latitude'], row['Longitude'])[1]
df['X'] = df.apply(get_X, axis=1)
df['Y'] = df.apply(get_Y, axis=1)
I'd like to define a function get_XY and apply from_latlon just one time to save time. I took a look at here, here and here but I could not find a way to make two columns with one apply function. Thanks.