Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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() argument must be a string or a number, not 'method'

I tried running it using a Pandas series then Numpy array but does not work.

like image 325
adityaverma Avatar asked Apr 24 '17 04:04

adityaverma


1 Answers

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 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

It should be as follows :

lat = subsamp['Latitude'].as_matrix()
long = subsamp['Longitude'].as_matrix()
like image 132
Surajano Avatar answered Nov 15 '22 09:11

Surajano