I use the codes below to identify address from latitude and longitude:
import pandas
df = pandas.read_csv("/Users/Downloads/address.csv", encoding='utf-8')
df['address'] = ''
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="http")
df['address'] = df.apply(
lambda row: geolocator.reverse((row['latitude'], row['longitude'])), axis=1)
county = df.raw['address']
The output is:
id | latitude | longitude | address |
---|---|---|---|
1 | 40.0175444 | -105.2833481 | 919, Pearl Street, Boulder, Boulder County, Colorado, 80302, United States |
2 | 39.94700652 | -82.997471 | 740, South High Street, Brewery District, Columbus, Franklin County, Ohio, 43206, United States |
I want to create two columns that store the name of county and 5-digit FIPS code. The last code shows the error: AttributeError: 'DataFrame' object has no attribute 'raw'