dtoolkit.geoaccessor.dataframe.geocode#
- dtoolkit.geoaccessor.dataframe.geocode(df: DataFrame, /, address: Hashable, drop: bool = False, **kwargs) GeoDataFrame[source]#
Geocode a string type column from a DataFrame and get a GeoDataFrame of the resulting points.
- Parameters
- addressHashable
The name of the column to geocode.
- dropbool, default False
Don’t contain the original data anymore.
- **kwargs
See the documentation for
geocode()for complete details on the keyword arguments.
- Returns
- GeoDataFrame
- Raises
- ModuleNotFoundError
If don’t have module named ‘geopy’.
Examples
>>> import dtoolkit.geoaccessor >>> import pandas as pd >>> df = pd.DataFrame( ... { ... "name": [ ... "boston, ma", ... "1600 pennsylvania ave. washington, dc", ... ], ... } ... ) >>> df name 0 boston, ma 1 1600 pennsylvania ave. washington, dc >>> df.geocode("name", drop=True) geometry address 0 POINT (-71.06051 42.35543) Boston, Massachusetts, United States 1 POINT (-77.03655 38.89770) White House, 1600, Pennsylvania Avenue Northwe...