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

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

      1. <tfoot id='WLd8v'></tfoot>

        <legend id='WLd8v'><style id='WLd8v'><dir id='WLd8v'><q id='WLd8v'></q></dir></style></legend>
          <bdo id='WLd8v'></bdo><ul id='WLd8v'></ul>

      2. np.isnan() == False,但 np.isnan() 不是 False

        np.isnan() == False, but np.isnan() is not False(np.isnan() == False,但 np.isnan() 不是 False)
        <legend id='gMMcz'><style id='gMMcz'><dir id='gMMcz'><q id='gMMcz'></q></dir></style></legend>
      3. <i id='gMMcz'><tr id='gMMcz'><dt id='gMMcz'><q id='gMMcz'><span id='gMMcz'><b id='gMMcz'><form id='gMMcz'><ins id='gMMcz'></ins><ul id='gMMcz'></ul><sub id='gMMcz'></sub></form><legend id='gMMcz'></legend><bdo id='gMMcz'><pre id='gMMcz'><center id='gMMcz'></center></pre></bdo></b><th id='gMMcz'></th></span></q></dt></tr></i><div id='gMMcz'><tfoot id='gMMcz'></tfoot><dl id='gMMcz'><fieldset id='gMMcz'></fieldset></dl></div>
      4. <small id='gMMcz'></small><noframes id='gMMcz'>

            <bdo id='gMMcz'></bdo><ul id='gMMcz'></ul>
            <tfoot id='gMMcz'></tfoot>
                  <tbody id='gMMcz'></tbody>
                1. 本文介绍了np.isnan() == False,但 np.isnan() 不是 False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  据我了解,== 检查值是否相等,is 检查值后面的结构的身份(例如 === 其他语言).

                  As far as I understand it, == checks for equality of value, and is checks for identity of structure behind value (as, say === in some other languages).

                  鉴于此,我不明白以下内容:

                  Given that, I don't understand the following:

                  np.isnan(30) == False
                  Out[19]: 
                  True
                  np.isnan(30) is False
                  Out[20]: 
                  False
                  

                  其他身份检查似乎并非如此:

                  It appears not to be the case with other identity checks:

                  (5 == 4) == False
                  Out[22]: 
                  True
                  (5 == 4) is False
                  Out[23]: 
                  True
                  

                  看起来好像 np.isnan() 返回 False 作为值,而不是作为标识.为什么会这样?

                  It appears as if np.isnan() returns False as a value, but not as identity. Why is that the case?

                  推荐答案

                  numpy.isnan() 返回一个compatible 类型的对象:

                  numpy.isnan() returns a compatible type object:

                  >>> import numpy
                  >>> type(numpy.isnan(0))
                  <class 'numpy.bool_'>
                  

                  这是一个自定义布尔值,可以有效地存储在 numpy 数组中,请参阅 Numpy 的 数据类型 文档.numpy.isnan() 函数也可以对数组进行操作,生成另一个数组并得到结果:

                  This is a custom boolean that can be stored efficiently in numpy arrays, see Numpy's Data Types documentation. The numpy.isnan() function can also operate on arrays, producing another array with results:

                  >>> numpy.isnan(numpy.array([1, 2]))
                  array([False, False], dtype=bool)
                  

                  dtype 又是 Numpy 布尔对象.

                  where again the dtype is the Numpy boolean object.

                  Python 不保证布尔运算必须始终返回单例布尔值.你永远不应该测试 is Trueis False anyway.在布尔运算中直接使用 numpy.isnan() 输出,使用 not 来测试假值:

                  Python makes no guarantees that boolean operations must always return a singleton boolean value. You should never test for is True or is False anyway. Use numpy.isnan() output directly in boolean operations, use not to test for false values:

                  if numpy.isnan(foo):
                  

                  if not numpy.isnan(bar):
                  

                  这篇关于np.isnan() == False,但 np.isnan() 不是 False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                    <tbody id='EJX4O'></tbody>

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

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

                          <bdo id='EJX4O'></bdo><ul id='EJX4O'></ul>
                          1. <legend id='EJX4O'><style id='EJX4O'><dir id='EJX4O'><q id='EJX4O'></q></dir></style></legend>