Let's consider the following numpy ndarray,
[[0],
[0],
[0],
[0],
[0],
[1],
[0]]
I want to make it to two column like,
A B
0 1 0
1 1 0
2 1 0
3 1 0
4 1 0
5 0 1
6 1 0
Now, I'm doing in the following way,
a = []
b = []
for i in lb_results:
if i == 0:
a.append(1)
b.append(0)
else:
a.append(0)
b.append(1)
lb_results = np.column_stack((a, b))
print(lb_results)
but I'm expecting something more optimized way, (less number of code lines are better, without using much more loops) Any suggestions would be grateful, Thanks.