numpy join entries intersecting at a cell
In numpy, how can I join the entries that intersects at a cell?
For example: Example http://img153.imageshack.us/img153/5162/matd.png
In the example, I want to join rows/columns B and F into one row/column BF, where each element is the average of the ones with t开发者_JAVA百科he same color.
What you want to do doesn't seem straightforward from a matrix point of view so doing in a "pure numpy" manner is likely unfeasible.
I'd probably break it up into 2 or 3 operations:
- Pull out row F, transpose it and average it with column B.
- Take the first value of the row F you pulled out and average it with the first value of row B.
- Pull out column F and average it with column B.
精彩评论