- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 Jupyter Notebook 中有以下数据框,其中包含一个 GPS 坐标列表,其中包含 from geopy.geocoders import Nominatim
和 import pandas as pd
。
stop_id Lat Long
0 2 53.352280 -6.263668
1 3 53.352345 -6.263758
2 4 53.352604 -6.264143
3 6 53.352783 -6.264417
4 7 53.352867 -6.264543
5 8 53.353287 -6.265152
我一直在尝试添加一个新列,其中填充了 GPS 坐标的相应地址。
为此我尝试过
df['address'] = geolocator.reverse((df['Lat'], df['Long']))
但得到以下错误信息:
ValueError: Must be a coordinate pair or Point.
然后我创建了另一列 [LatLong]
df['LatLong'] = df[df.columns[1:]].apply(
lambda x: ', '.join(x.dropna().astype(float).astype(str)),axis=1)
stop_id Lat Long LatLong
0 2 53.352280 -6.263668 53.35228, -6.263668
1 3 53.352345 -6.263758 53.352345, -6.263758
2 4 53.352604 -6.264143 53.352604, -6.264143
3 6 53.352783 -6.264417 53.352783, -6.264417
4 7 53.352867 -6.264543 53.352867, -6.264543
5 8 53.353287 -6.265152 53.353287, -6.265152
然后我运行了下面的代码:
df['address'] = geolocator.reverse(df['LatLong'])
但是,我只收到完全相同的错误消息。
我上面使用的代码改编自本网站上对类似问题和 GeoPy 文档的其他答案,因此我认为我的代码不够准确,无法以正确的方式为 geopy 提取 GPS 坐标。
谁能指出我的错误吗?
最佳答案
您的错误信息是:
ValueError: Must be a coordinate pair or Point
在两者中:
df['address'] = geolocator.reverse((df['Lat'], df['Long']))
和
df['address'] = geolocator.reverse(df['LatLong'])
您正在将 pandas 结构发送到一个不理解它们的方法中。
我无法对此进行测试,但解决方案可能类似于:
df['address'] = df.apply(
lambda row: geolocator.reverse((row['Lat'], row['Long'])), axis=1)
关于python - 反向geopy地理编码 Pandas ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45400288/
我正在使用 VS,我正在尝试运行 geopy,我安装了所有先决条件并收到此错误 “ModuleNotFoundError:没有名为‘geopy.geocoders’的模块;‘geopy’不是包” fr
我已经安装了geopy pip install geopy 我检查了我的命令行,它就在那里。 但是每当我尝试在 Anaconda、PyCharm 或 Jupiter Notebooks 中使用它时,我
from geopy.distance import vincenty 我刚刚安装了 geopy 包 2.0.0,我想像 doc 所说的那样使用 geopy.distance.vincenty()。但
我正在尝试使用 geopy 获取城市和国家名称。 通常这是使用 geopy 获取城市和国家/地区的方法。 from geopy.geocoders import Nominatim geolocato
我正在尝试使用 geopy 反转地理编码坐标并检索相应的国家/地区代码。但是,Geopy 似乎没有提供获取国家/地区代码的方法。因此,我试图首先检索国家/地区名称,然后将它们转换为代码。不幸的是,我的
我正在尝试将加拿大邮政编码转换为经纬度坐标,但是 geopy 将它们返回为“无”或位于不同国家/地区的某个地方 postal_code = "A1B 2C3" #<-- in this format
我正在尝试使用 GeoPy 将一些地址转换为数据框中的坐标。有些地址无效,但我不知道是哪些地址。因此,我需要库跳过无效的字段或将它们更改为 Null 或至少提出错误的确切字段。 以下工作正常: imp
我已经将 geopy 用于 python 项目大约两个月了。我可能使用代码不到 100 次,一次获得一个返回。所以我不认为我在滥用它。 昨天我收到超时错误,今天我收到以下错误: geopy.exc.G
我有一些带有错误处理的 Python 代码,但出于某种原因,代码似乎仍然无法处理这个特定错误: raise GQueryError("No corresponding geographic locat
我正在尝试在 Python 中安装 Geopy。我如何用非常简单的术语来做到这一点?我安装了 Python 3.4.0 启动器。我在哪里编写 Geopy 安装命令?在扩展名为 .py 的文本文件上?还
我正在根据邮政编码计算纬度和经度。 我已经安装了geopy pip install geopy 在我的代码中: from geopy.geocoders import GoogleV3 def get
我正在使用 geopy 对一些地址进行地理编码,我想捕捉超时错误并将它们打印出来,以便我可以对输入进行一些质量控制。我将地理编码请求放在 try/catch 中,但它不起作用。关于我需要做什么的任何想
以下脚本可以完美处理包含 2 行的文件,但是当我尝试 2500 行文件时,出现 429 个异常。所以,我将查询时间增加到 5 秒。我还填写了用户代理。尝试失败后,我连接到 VPN 以更改“新鲜”,但我
背景 我想添加一个模型管理器函数,该函数根据与坐标的接近度过滤查询集。我找到了这个blog posting代码完全符合我的要求。 代码 下面的代码片段似乎使用了 geopy此后已删除的功能。它通过限制
背景 我想添加一个模型管理器函数,该函数根据与坐标的接近度过滤查询集。我找到了这个blog posting代码完全符合我的要求。 代码 下面的代码片段似乎使用了 geopy此后已删除的功能。它通过限制
我有一个充满十进制格式的经度/纬度对的表(例如,-41.547、23.456)。我想以 "Easting and Northing"/UTM 格式显示值。 geopy是否提供了从十进制转换为UTM的方
我正在尝试在 pyCharm 中运行 python 程序,但出现此错误: Traceback (most recent call last): File "/Users/amywang/Documen
我正在使用 geopy 获取城市名称的纬度-经度对。对于单个查询,这工作得很好。我现在尝试做的是迭代城市名称的大列表(46.000)并获取每个城市的地理编码。然后,我通过一个检查循环运行它们,将城市(
我刚开始使用 GeoPy。我需要将给定位置转换为纬度和经度。但是我收到 GeocoderQuotaExceeded 错误。我只是按照文档中给出的示例进行操作。任何帮助将不胜感激。 from geopy
我是一个相对较新的 Python 用户,我正在尝试使用一个函数来使用“geopy”模块返回城市和国家/地区的纬度和经度。我有错误,因为我的城市拼错了,我设法 catch 了。我现在遇到的麻烦是我遇到超
我是一名优秀的程序员,十分优秀!