TypeError:float()参数必须是字符串或数字,而不是“方法" [英] TypeError: float() argument must be a string or a number, not 'method'
问题描述
我正在尝试将纬度和经度转换为大约1万个数据点的邮政编码.我正在使用Geocoder来完成任务.
I am trying to convert the latitude and longitude to zipcodes for around 10k data points. I am using geocoder for the task.
lat = subsamp['Latitude'].as_matrix
long = subsamp['Longitude'].as_matrix
g = geocoder.google([lat, long], method='reverse')
zip = g.postal
但是,在执行地址解析器时,出现错误:
But, on executing the geocoder I get the error:
TypeError:float()参数必须是字符串或数字,而不是方法"
TypeError: float() argument must be a string or a number, not 'method'
我尝试使用Pandas系列然后运行Numpy数组来运行它,但是不起作用.
I tried running it using a Pandas series then Numpy array but does not work.
推荐答案
Its a Missing parentheses issue for .as_matrix
,
pandas.DataFrame.as_matrix, is a method
used to convert the frame to its Numpy-array representation.
由于它是一个函数,所以您错过了()
,没有为.as_matrix
添加()
函数括号.
As it is a function, you missed the ()
, you have not added ()
function parenthesis, for .as_matrix
.
lat = subsamp['Latitude'].as_matrix
long = subsamp['Longitude'].as_matrix
应如下所示:
lat = subsamp['Latitude'].as_matrix()
long = subsamp['Longitude'].as_matrix()
这篇关于TypeError:float()参数必须是字符串或数字,而不是“方法"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!