Looping through each item in a numpy array?

前端 未结 3 772
梦如初夏
梦如初夏 2021-01-27 09:08

I\'m trying to access each item in a numpy 2D array.

I\'m used to something like this in Python [[...], [...], [...]]

for row in data:
    for col in dat         


        
3条回答
  •  轮回少年
    2021-01-27 09:31

    If you want to access an item in a numpy 2D array features, you can use features[row_index, column_index]. If you wanted to iterate through a numpy array, you could just modify your script to

    for row in data:
    
        for col in data:
    
           print(data[row, col])
    

提交回复
热议问题