<bdo id='21iaD'></bdo><ul id='21iaD'></ul>

      <i id='21iaD'><tr id='21iaD'><dt id='21iaD'><q id='21iaD'><span id='21iaD'><b id='21iaD'><form id='21iaD'><ins id='21iaD'></ins><ul id='21iaD'></ul><sub id='21iaD'></sub></form><legend id='21iaD'></legend><bdo id='21iaD'><pre id='21iaD'><center id='21iaD'></center></pre></bdo></b><th id='21iaD'></th></span></q></dt></tr></i><div id='21iaD'><tfoot id='21iaD'></tfoot><dl id='21iaD'><fieldset id='21iaD'></fieldset></dl></div>
      <legend id='21iaD'><style id='21iaD'><dir id='21iaD'><q id='21iaD'></q></dir></style></legend>
    1. <small id='21iaD'></small><noframes id='21iaD'>

    2. <tfoot id='21iaD'></tfoot>
    3. Numpy:快速找到第一个价值索引

      Numpy: find first index of value fast(Numpy:快速找到第一个价值索引)
        <bdo id='x0DGk'></bdo><ul id='x0DGk'></ul>
        1. <tfoot id='x0DGk'></tfoot>
        2. <i id='x0DGk'><tr id='x0DGk'><dt id='x0DGk'><q id='x0DGk'><span id='x0DGk'><b id='x0DGk'><form id='x0DGk'><ins id='x0DGk'></ins><ul id='x0DGk'></ul><sub id='x0DGk'></sub></form><legend id='x0DGk'></legend><bdo id='x0DGk'><pre id='x0DGk'><center id='x0DGk'></center></pre></bdo></b><th id='x0DGk'></th></span></q></dt></tr></i><div id='x0DGk'><tfoot id='x0DGk'></tfoot><dl id='x0DGk'><fieldset id='x0DGk'></fieldset></dl></div>

            <small id='x0DGk'></small><noframes id='x0DGk'>

            <legend id='x0DGk'><style id='x0DGk'><dir id='x0DGk'><q id='x0DGk'></q></dir></style></legend>

              <tbody id='x0DGk'></tbody>

                本文介绍了Numpy:快速找到第一个价值索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何在 Numpy 数组中找到第一次出现的数字的索引?速度对我来说很重要.我对以下答案不感兴趣,因为它们会扫描整个数组并且在发现第一次出现时不会停止:

                How can I find the index of the first occurrence of a number in a Numpy array? Speed is important to me. I am not interested in the following answers because they scan the whole array and don't stop when they find the first occurrence:

                itemindex = numpy.where(array==item)[0][0]
                nonzero(array == item)[0][0]
                

                注意 1:该问题的答案似乎都不相关 是否有一个 Numpy 函数可以返回数组中某物的第一个索引?

                Note 1: none of the answers from that question seem relevant Is there a Numpy function to return the first index of something in an array?

                注意 2:使用 C 编译的方法优于 Python 循环.

                Note 2: using a C-compiled method is preferred to a Python loop.

                推荐答案

                有一个针对 Numpy 2.0.0 计划的功能请求:https://github.com/numpy/numpy/issues/2269

                There is a feature request for this scheduled for Numpy 2.0.0: https://github.com/numpy/numpy/issues/2269

                这篇关于Numpy:快速找到第一个价值索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                How to extend Python class init(如何扩展 Python 类初始化)
                What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                Initialize list with same bool value(使用相同的布尔值初始化列表)
                setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                • <tfoot id='zFAEY'></tfoot>
                    <bdo id='zFAEY'></bdo><ul id='zFAEY'></ul>

                      <tbody id='zFAEY'></tbody>

                    <small id='zFAEY'></small><noframes id='zFAEY'>

                  • <i id='zFAEY'><tr id='zFAEY'><dt id='zFAEY'><q id='zFAEY'><span id='zFAEY'><b id='zFAEY'><form id='zFAEY'><ins id='zFAEY'></ins><ul id='zFAEY'></ul><sub id='zFAEY'></sub></form><legend id='zFAEY'></legend><bdo id='zFAEY'><pre id='zFAEY'><center id='zFAEY'></center></pre></bdo></b><th id='zFAEY'></th></span></q></dt></tr></i><div id='zFAEY'><tfoot id='zFAEY'></tfoot><dl id='zFAEY'><fieldset id='zFAEY'></fieldset></dl></div>
                    <legend id='zFAEY'><style id='zFAEY'><dir id='zFAEY'><q id='zFAEY'></q></dir></style></legend>