我正在尝试将纬度和经度转换为大约 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/