Skip to content

Conversation

@vk496
Copy link

@vk496 vk496 commented Apr 12, 2025

#7

Feel free to edit as you wish

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! a few comments below and this also needs some unit tests.


Args:
lat (float): latitude
lon (float): longitude
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use numpy style docstring.


return pd.DataFrame(columns=self._data.columns)

def query_geocode(self, lat: float, lon: float):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call it query_coordinates maybe.

Also I think it would be better to also add a top_k: int=1 param and returns a dataframe not a series, similar to how query_location works. Add the return type annotations.

np.array([[lat, lon]]), np.array([[row["latitude"], row["longitude"]]])
),
axis=1,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can build the array of coordinates _data_frame and pass it to haversine_distance directly (it should work with arrays of shape N, that would be faster.

nearest_index = distances.idxmin()

# Return the nearest row
nearest_row = self._data_frame.loc[nearest_index].copy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can argsort distances and return top_k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants