## How to convert a binary classes column to numpy array

Question

I have an array like this as the label column (2 labels : 0 and 1) , for example:

```
[0,1,0,1,1]
```

Supposed that I want to convert this array to a numpy matrix with the shape (5,2) (5 elements, 2 labels) . How can I do that in a trivial way by using any util library?

The outcome I want is like this :

```
[[0,1][1,0],[0,1],[1,0],[1,0]]
```

Show source

## Answers ( 1 )

You could use

`NumPy broadcasting`

-Sample run -