I need to insert arbitrary number of zeros to alternate rows and columns of a numpy array. For example, lets suppose that we want to insert 1 zero in all alternate columns and rows.
Input => [[ 1,2,3],
[ 4,5,6],
[ 7,8,9]]
output => [[ 1,0,2,0,3],
[ 0,0,0,0,0],
[ 4,0,5,0,6],
[ 0,0,0,0,0],
[ 7,0,8,0,9]]
I know how this can be achieved by using loops but I'm not sure if that's the most efficient way or there is some vectorized implementation possible .