Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def location_name_extraction(x):
- temp_location = geolocator.reverse('"'+x.stop_lat_lng+'"', timeout=30)
- #print(temp_location.raw)
- if 'state_district' in temp_location.raw['address'].keys() and 'state' in temp_location.raw['address'].keys():
- x1 = temp_location.raw['address']['state_district']
- y1 = temp_location.raw['address']['state']
- else:
- x1 = 'Not Available'
- y1 = 'Not Available'
- print("x: ", x1)
- print("y: ", y1)
- x["district"] = x1
- x["state"] = y1
- return x
- #return x, y
- temp = temp.apply(lambda x: location_name_extraction(x), axis=1)
Add Comment
Please, Sign In to add comment