add country code and city to a dataset given coordinates

24 views Asked by At

How can I add country code and city given coordinates . The coordinates exists as a column with values like (52.3992723, 13.3883492). I am using code workbook to do this .

Sample dataset

Person,Coordinates
Id1, 52.3992723, 13.3883492
Id2, 57.3992723, 13.3883492

Code Sample :

import reverse_geocoder as rg
from pyspark.sql import functions as F

map_state = F.udf(lambda x : rg.search(x)[0]['admin2'])
return(df.withColumn('newCol',map_state(F.col('coordinates'))))
0

There are 0 answers