views:

56

answers:

1

In numpy, how can I join the entries that intersects at a cell?

For example: Example

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 the same color.

+1  A: 

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:

  1. Pull out row F, transpose it and average it with column B.
  2. Take the first value of the row F you pulled out and average it with the first value of row B.
  3. Pull out column F and average it with column B.
Nick T