You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GeoResolver is a lightweight Python library for resolving place names into geographic coordinates and related metadata using multiple gazetteer services, including [GeoNames](https://www.geonames.org/), [WHG](https://whgazetteer.org/), [Wikidata](https://www.wikidata.org/wiki/Wikidata:Main_Page), and [TGN](https://www.getty.edu/research/tools/vocabularies/tgn/).
self.logger.warning(f"Invalid country code: {country_code}\nLook at the correct ISO 3166-1 alpha-2 country codes at https://www.iso.org/iso-3166-country-codes.html")
self.logger.warning(f"Invalid country code: {country_code}\nLook at the correct ISO 3166-1 alpha-2 country codes at https://www.iso.org/iso-3166-country-codes.html")
923
+
country_code=None
924
+
exceptExceptionase:
925
+
self.logger.info(f"Error occurred while validating country code: {e}")
923
926
924
927
ifself.flexible_thresholdandlen(place_name) <5:
925
928
self.logger.warning(
@@ -972,12 +975,16 @@ def resolve_batch(
972
975
) ->Union[pd.DataFrame, List[dict]]:
973
976
"""
974
977
Resolve coordinates for a batch of places from a DataFrame.
978
+
979
+
This method optimizes API calls by processing only unique combinations of
980
+
place_name, country_code, and place_type, then mapping results back to the original DataFrame.
975
981
976
982
Args:
977
983
df (pd.DataFrame): Input DataFrame with place names and optional country/type columns.
978
984
place_column (str): Column name for place names.
979
985
country_column (str): Column name for country codes (optional).
980
986
place_type_column (str): Column name for place types (optional).
987
+
use_default_filter (bool): If True, apply a default filter as fallback.
981
988
return_df (bool): If True, return a DataFrame with separate columns for each attribute. Otherwise, return a list of dictionaries.
982
989
show_progress (bool): If True, show a progress bar during processing.
983
990
@@ -988,11 +995,6 @@ def resolve_batch(
988
995
pd.DataFrame: A DataFrame with resolved coordinates and metadata.
989
996
List[dict]: A list of dictionaries with resolved coordinates and metadata if return_df is False.
990
997
"""
991
-
#TODO:
992
-
# - Gently handle NaN and empty strings in place_column
993
-
# - Process data in chunks of 100 rows
994
-
# - Only process records with valid place names (non-empty strings)
995
-
# - Sort Series
996
998
997
999
ifnotisinstance(df, pd.DataFrame):
998
1000
raiseValueError("Input must be a pandas DataFrame")
0 commit comments