I have a city + state information and I'm trying to find the county. I tried a few things. The closest I got is using geopy. Here is an example:
from geopy.geocoders import Nominatim
geolocator = Nominatim()
loc = geolocator.geocode('Chicago Illinois')
print(loc.address)
# u'Chicago, Cook County, Illinois, United States of America'
loc = geolocator.geocode('San Francisco California')
print(loc.address)
# u'SF, California, United States of America'
The problem is that it is unclear if the county is part of the output and if it is how to extract it using code (the string format seems to change).
What is the best way to get County information for a city + state?