I have the following code which  duplicates the previous input if any entry is less than zero or NaN, except the first row of a matrix.Is there any other efficient way to do this without using multiple for loops? The input matrix values may differ in some case and may contain float values or alphabets. The matrix considered here is just an example. The actual table will be 14352 x 42 in shape.import numpy as npdata = [[0, -1, 2],        [7, 8.1, -3],        [-8, 5, -1],        ['N', 7, -1]]m, n = np.shape(data)for i in range(1, m):    for j in range(n):        if data[i][j] < 0 or not isinstance(data[i][j], (int, float,long)):            data[i][j] = data[i-1][j]The output is:[[0,-1,2], [7,8.1,2], [7,5,2], [7,7,2]]
Duplicate the previous input if zero or not a number
python;matrix;numpy