I am trying to convert a vector from A-L to something like this with pandas and numpy built in functions without loops (tile, repeat and reshape). But I cannot wrap my head around
0 1 2 3 4 5 6 7 8 9 10 11
0 A A A A E E E E I I I I
1 B B B B F F F F J J J J
2 C C C C G G G G K K K K
3 D D D D H H H H L L L L
4 A A A A E E E E I I I I
5 B B B B F F F F J J J J
6 C C C C G G G G K K K K
7 D D D D H H H H L L L L
Do you have any ideas how I could do that without loops ?
what I have tried so far:
a = np.array(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'])
b = a.reshape(3,4)
np.repeat(b, 4).reshape(4,12)
gives me:
array([['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C'],
['D', 'D', 'D', 'D', 'E', 'E', 'E', 'E', 'F', 'F', 'F', 'F'],
['G', 'G', 'G', 'G', 'H', 'H', 'H', 'H', 'I', 'I', 'I', 'I'],
['J', 'J', 'J', 'J', 'K', 'K', 'K', 'K', 'L', 'L', 'L', 'L']],
dtype='<U1')
EDIT: Some background. Depending on the number of samples and the layout we choose. A machine, creates plates (like in this image). We can do consecutive operations (add more chemicals etc.) and based on the previous layout, unique combinations are obtained. Afterwards the machine measures e.g. concentration in each well and I would like to link the output to the conditions in each well. Because the machine can measure e.g. concentration after each step, a lot of data can be generated and I am trying to find a generic solution without too many loops.