0

I am new to python and I am doing an apprenticeship at work, I have the following code but it is not adding the longitude and latitude to my data frame, can anyone point me in the right direction?

import pandas as pd
from geopy.geocoders import Nominatim
sales = pd.read_csv('file_path/ppd_data.csv')

sales['co-ordinates'] = sales['postcode'].apply(geolocator.geocode).apply(lambda x: (x.latitude, x.longitude))
sales

sales.head()

Hoping to get the longitude and latitude into the main data frame.

Table This data is from the land registry and I want to add the longitude and latitude for creating the mapping points.

DLR
  • 3
  • 2
  • 3
    Some sample data would be helpful. – Mark Kram Aug 08 '23 at 19:18
  • 2
    We need to know what `geolocator` is, and what your data looks like. Have a look at https://stackoverflow.com/help/minimal-reproducible-example – Matt Hall Aug 08 '23 at 19:31
  • Your question needs a minimal reproducible example consisting of sample input, expected output, actual output, and only the relevant code necessary to reproduce the problem. See [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) for best practices related to Pandas questions. – itprorh66 Aug 08 '23 at 23:52

0 Answers0