Guest User

Untitled

a guest
Dec 11th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def location_name_extraction(x):
  2. temp_location = geolocator.reverse('"'+x.stop_lat_lng+'"', timeout=30)
  3. #print(temp_location.raw)
  4. if 'state_district' in temp_location.raw['address'].keys() and 'state' in temp_location.raw['address'].keys():
  5. x1 = temp_location.raw['address']['state_district']
  6. y1 = temp_location.raw['address']['state']
  7. else:
  8. x1 = 'Not Available'
  9. y1 = 'Not Available'
  10.  
  11. print("x: ", x1)
  12. print("y: ", y1)
  13. x["district"] = x1
  14. x["state"] = y1
  15. return x
  16. #return x, y
  17.  
  18.  
  19. temp = temp.apply(lambda x: location_name_extraction(x), axis=1)
Add Comment
Please, Sign In to add comment