简体   繁体   English

python 3在float32中追加数组?

[英]Python 3 append array in float32?

When I loop through my data, a .csv file and assign values from each row to a array element // I need the values to be float32, how do I do that ? 当我遍历数据,.csv文件并将每行的值分配给数组元素时,//我需要将值设置为float32,该怎么做? this works, but they are not the type that I want ? 这有效,但是它们不是我想要的类型吗? Basemap complains, Thanks! 底图抱怨,谢谢!

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 ?

Assuming you mean numpy.float32 (There is nothing called that in vanilla python): 假设您的意思是numpy.float32(香草python中没有这样的名称):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 包含数组float32元素的字典 - Dictionary containing array float32 element 将多维numpy数组的元素转换为float32 - Convert elements of multi-dimensional numpy array to float32 将 float32 数据类型的 numpy 数组转换为十六进制格式 - Convert numpy array of float32 data type to hex format Numpy的float32和float比较 - Numpy's float32 and float comparisons 在 Python 中直接打印 `float32` 和使用 `format()` 函数的区别 - Difference between printing `float32` directly and using `format()` function in Python 为什么我的模型即使在 >93 准确度后也给出相同的结果? 结果 >> 数组([[1., 0., 0.]], dtype=float32) - why my model is giving same result even after >93 accuracy ? result >> array([[1., 0., 0.]], dtype=float32) 以与 scipy.misc.imresize 或 tf.image.resize 相同的方式使用 K-最近邻调整 float32 数组的大小 - Resize float32 array with K-nearest neighbour in the same way as scipy.misc.imresize or tf.image.resize tensorflow float32的转换与java对象不兼容 - Conversion of tensorflow float32 is incompatible with a java object Pandas df.astype('float32') 失去了很多精度 - Pandas df.astype('float32') loses a lot of precision 用户警告:警告:通过强制转换为 float32 会降低框边界精度 - UserWarning: WARN: Box bound precision lowered by casting to float32
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM