Jun-14-2019, 04:58 PM
You can do this very fast with numpy
import numpy as np a = np.array([[58, 68, 58, 59, -1, -1], [59, 69, 59, -1, -1, -1], [93, 94, 93, 33, -1, -1], [58, 59, 58, 68, -1, -1], [92, 94, 92, 33, -1, -1]]) print(np.sum((a != -1), axis=1))which outputs a list with the "length" of each row
Quote:[4 3 4 4 4]