I require the following logic:
- The output array has the same amount of rows as the number of elements in the input array
- The values of the input array denote the column numbers of the output array (the number of columns equals the maximum number in the input array)
- The output array's values should be 1 if the input array contains the specific combination, 0 otherwise
For example, I'd like to transform a numpy array such as
[2, 1, 1, 0]
into an array that looks like this
[[0, 0, 1],
[0, 1, 0],
[0, 1, 0],
[1, 0, 0]]
The only thing I can come up with is filling an empty array with a for-loop. Any more "numpy-ish" way to do this?