import numpy as np
input_matrix = np.array([
[1, 2, 3, 0],
[4, 5, 6, 1],
[3, 6, 7, 0]
])
rows_to_insert = np.where(input_matrix[:, 3] == 1)[0]
for row in reversed(rows_to_insert):
new_row = np.copy(input_matrix[row])
input_matrix = np.insert(input_matrix, row, new_row, axis=0)
input_matrix = np.insert(input_matrix, row + 2, new_row, axis=0)
input_matrix[row , 3] = 0
input_matrix[row + 2, 3] = 0
# 結果を表示
for row in input_matrix:
print(row)