为什么 return 值只有 nan?
why return value is only nan?
这是我尝试使用的代码 运行,但我没有得到输出中的值,
import numpy
import geocoder
data = numpy.loadtxt(fname = 'Flywheel_SF.csv', delimiter = ',', dtype = numpy.ndarray)
start = list()
end = list()
z_code = numpy.zeros((101,2))
for i in range(1,101):
s = geocoder.google([data[i,4], data[i,5]], method='reverse')
e = geocoder.google([data[i,6], data[i,7]], method='reverse')
start.append(s.postal)
end.append(e.postal)
z_code[i,0] = s.postal
z_code[i,1] = e.postal
zipcode = [start, end]
print(z_code)
这是我得到的输出,
[[ 0. 0.]
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
....
....
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]]
输出应该是这样的,这些是经纬度转换后的邮政编码
[[ 0. 0.]
[ 94105. 94103.]
[ 94133. 94108.]
[ 94133. 94133.]
[ 94114. 94122.]
[ 94104. 94128.]
[ 94128. 94066.]
......
......
[ 94128. 94066.]
[ 94118. 94116.]
[ 94109. 94102.]]
请帮忙,先谢谢了!
一个可能的原因是您发送给 google api 的请求数量。
您每天只能拨打 google api 2500 次。
欲了解更多详情,请阅读:
https://developers.google.com/maps/documentation/geocoding/usage-limits
这是我尝试使用的代码 运行,但我没有得到输出中的值,
import numpy
import geocoder
data = numpy.loadtxt(fname = 'Flywheel_SF.csv', delimiter = ',', dtype = numpy.ndarray)
start = list()
end = list()
z_code = numpy.zeros((101,2))
for i in range(1,101):
s = geocoder.google([data[i,4], data[i,5]], method='reverse')
e = geocoder.google([data[i,6], data[i,7]], method='reverse')
start.append(s.postal)
end.append(e.postal)
z_code[i,0] = s.postal
z_code[i,1] = e.postal
zipcode = [start, end]
print(z_code)
这是我得到的输出,
[[ 0. 0.]
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
....
....
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]
[ nan nan]]
输出应该是这样的,这些是经纬度转换后的邮政编码
[[ 0. 0.]
[ 94105. 94103.]
[ 94133. 94108.]
[ 94133. 94133.]
[ 94114. 94122.]
[ 94104. 94128.]
[ 94128. 94066.]
......
......
[ 94128. 94066.]
[ 94118. 94116.]
[ 94109. 94102.]]
请帮忙,先谢谢了!
一个可能的原因是您发送给 google api 的请求数量。 您每天只能拨打 google api 2500 次。
欲了解更多详情,请阅读: https://developers.google.com/maps/documentation/geocoding/usage-limits