gpt4 book ai didi

python - TypeError : float() argument must be a string or a number, 不是 'method'

转载 作者:太空狗 更新时间:2023-10-30 02:08:24 24 4
gpt4 key购买 nike

我正在尝试将纬度和经度转换为大约 10k 个数据点的邮政编码。我正在使用地理编码器来完成这项任务。

lat = subsamp['Latitude'].as_matrix
long = subsamp['Longitude'].as_matrix

g = geocoder.google([lat, long], method='reverse')

zip = g.postal

但是,在执行地理编码器时出现错误:

TypeError: float() argument must be a string or a number, not 'method'

我尝试使用 Pandas 系列然后使用 Numpy 数组运行它,但不起作用。

最佳答案

.as_matrix 缺少括号问题,<强> pandas.DataFrame.as_matrix , 是一种方法用于将框架转换为其 Numpy 数组表示形式。

因为它是一个函数,你错过了 (),你没有添加 () 函数括号,对于 .as_matrix

lat = subsamp['Latitude'].as_matrix
long = subsamp['Longitude'].as_matrix

应该是这样的:

lat = subsamp['Latitude'].as_matrix()
long = subsamp['Longitude'].as_matrix()

关于python - TypeError : float() argument must be a string or a number, 不是 'method',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43579753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com