def _feature_most_common(self, results):
"""
Find the most common country name in ES/Geonames results
Paramaters
----------
results: dict
output of `query_geonames`
Returns
-------
most_common: str
ISO code of most common country, or empty string if none
"""
try:
country_count = Counter([i['country_code3'] for i in results['hits']['hits']])
most_common = country_count.most_common()[0][0]
return most_common
except IndexError:
return ""
except TypeError:
return ""
评论列表
文章目录