I have two big numpy arrays or pandas dataframes, eg:
a=[[1, 10, 20, 30],[2, 50, 14, -10],[3, 11, 2, 0], ...]
b=[[10, 40, 30, 1, 1, 2],[0, 11, -1, 32, 3, 2],[9, 2, 51, -2, 3, 2], ...]
I want to replace last two columns of the matrix b with values of a. I want to say when in the last two columns of a, we have 1, replace with the row in the a which contains 1 as the first column of a. this column is a counter from 1 to end. In fact at the end the columns of matrix b will be increased from 6 to 10.
So, the new b will be something like:
b=[[10, 40, 30, 1, 10, 20, 30, 50, 14, -10],[0, 11, -1, 32, 11, 2, 0, 50, 14, -10],[9, 2, 51, -2, 10, 20, 30, 11, 2, 0], ...]
I appreciate any solution to handle this request with the data either as numpy arrays or pandas.
bwere indices of these 1 * 3 blocks to be replaced with.