for i in range(len(data)): if data[i,-1] == 2: clear_arr = np.delete(data,i,axis=0) print(clear_arr)
时间: 2024-06-05 13:06:21 浏览: 100
This code iterates through each row in the "data" array using a for loop with the range function.
For each row, it checks if the last element (indicated by "-1") is equal to 2.
If the last element is 2, it uses the numpy "delete" function to remove that entire row from the "data" array, creating a new array called "clear_arr".
Finally, it prints the "clear_arr" array.
Overall, this code appears to be removing any rows from the "data" array where the last element is equal to 2.
阅读全文