admin管理员组文章数量:1400286
I am using pgeocode library to fetch city and state from pincodes. The library works fine for most countries, but not for Canada.
I cross checked with suggested country list and CA is one of them. Also, I remember me testing CA before and cant recollect having issues before. I am using this library in a npm library package. This is my server.py
country = data.get("country")
postal_code = data.get("postal_code")
if not country or not postal_code:
return jsonify({"error": "Country and postal code are required"}), 400
nomi = pgeocode.Nominatim(country)
location = nomi.query_postal_code(postal_code)
if location.empty:
return jsonify({"error": "Invalid postal code"}), 404
return jsonify({
"country": country,
"postal_code": postal_code,
"city": location.place_name,
"state": location.state_name
})
This is what I receive and when I input postal code as "L2P2K6" and country as "CA", this is what it returns:
==counytry nomi CA
==counytry location postal_code L2P2K6
country_code NaN
place_name NaN
state_name NaN
state_code NaN
county_name NaN
county_code NaN
community_name NaN
community_code NaN
latitude NaN
longitude NaN
accuracy NaN
Name: 0, dtype: object
What am I doing wrong?
I am receiving positive response for most of the other postal codes. Example:
==counytry nomi US
==counytry location postal_code 60602
country_code US
place_name Chicago
state_name Illinois
state_code IL
county_name Cook
county_code 31.0
community_name NaN
community_code NaN
latitude 41.8829
longitude -87.6321
accuracy 4.0
本文标签: pythonpgeocode not returning CA locationsStack Overflow
版权声明:本文标题:python - pgeocode not returning CA locations - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744184131a2594207.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论