Python 3在float32中追加数组?

时间:2016-10-07 21:29:43

标签: python-3.x

当我遍历我的数据,.csv文件并将每行的值分配给数组元素//我需要将值设置为float32,我该怎么做?这有效,但它们不是我想要的类型?底图抱怨,谢谢!

csvReader = csv.reader(stores)
header = next(csvReader, None)
latIndex = header.index("lati")
lonIndex = header.index("long")

# Make an empty list
coordList = []

# Loop through the lines in the file and get each coordinate
for row in csvReader:
    lat = row[latIndex]
    lon = row[lonIndex]
    result = (lat, lon)
    coordList.append(result)    # how to make it float32 ?

1 个答案:

答案 0 :(得分:0)

假设你的意思是numpy.float32(在vanilla python中没有任何东西叫它):

lat = numpy.float32(row[latIndex])
lon = numpy.float32(row[lonIndex])