numpy 连接条目在单元格处相交

发布于 2024-09-09 06:52:43 字数 244 浏览 3 评论 0原文

在 numpy 中,如何加入在单元格处相交的条目?

例如:示例 http://img153.imageshack.us/img153/5162/matd。 png

在示例中,我想将行/列 B 和 F 连接成一行/列 BF,其中每个元素是具有相同颜色的元素的平均值。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画尸师 2024-09-16 06:52:43

从矩阵的角度来看,您想要做的事情似乎并不简单,因此以“纯 numpy”方式进行可能是不可行的。

我可能会将其分为 2 或 3 个操作:

  1. 拉出 F 行,转置它并与 B 列进行平均。
  2. 取您拉出的 F 行的第一个值,并将其与 B 行的第一个值进行平均
  3. 。取出 F 列并与 B 列进行平均。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文