[英]Python 3 append array in float32?
當我遍歷數據,.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 ?
假設您的意思是numpy.float32(香草python中沒有這樣的名稱):
lat = numpy.float32(row[latIndex])
lon = numpy.float32(row[lonIndex])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.