I am trying to convert data in a Pandas column (containing IP address in each row) to latitude and longitude. Below are my codes:
import geocoder
d = pd.DataFrame({'ip_address' : ['49.206.217.180', '200.8.245.246', '186.188.35.217']})
d['coordinate'] = d.apply(geocoder.ip(d['ip_address'].latlng))
After running these codes I got an error
AttributeError: 'Series' object has no attribute 'latlng'
I am not sure why it does that. Could anyone provide me some feedbacks here? Really appreciate it.
import geocoder
d = pd.DataFrame({'ip_address' : ['49.206.217.180', '200.8.245.246', '186.188.35.217']})
d['coordinate'] = d['ip_address'].apply(lambda x: geocoder.ip(x).latlng)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.