代码之家  ›  专栏  ›  技术社区  ›  ipramusinto

Pandas isna()和isnull(),有什么区别?

  •  15
  • ipramusinto  · 技术社区  · 8 年前

    isna() 和 isnull() . 我通常用 isnull() 为了检测丢失的值和从未遇到过的情况,所以我不得不使用其他的方法。 那么,什么时候使用 ?

    2 回复  |  直到 8 年前
        1
  •  49
  •   qsantos    7 年前

    isnull 是的别名 isna code source of pandas

    isnull = isna
    

    的确:

    >>> pd.isnull
    <function isna at 0x7fb4c5cefc80>
    

    所以我建议使用 .

        2
  •  6
  •   Tam Le    8 年前

    两者的文档完全相同。

    熊猫.isna() : https://pandas.pydata.org/pandas-docs/stable/generated/pandas.isna.html#pandas.isna

    https://pandas.pydata.org/pandas-docs/stable/generated/pandas.isnull.html#pandas.isnull

    在这里,它甚至说DataFrame.isnull是isna的别名,请参见另一节。

    pandas.DataFrame.isnull(): https://pandas-docs.github.io/pandas-docs-travis/generated/pandas.DataFrame.isnull.html#pandas.DataFrame.isnull

    因此,它们必须是同一件事,比如np.nan公司, np.NaN公司, np.NAN公司.

        3
  •  4
  •   Jyoti Prasad Pal    7 年前

    isna() 结束 isnull() .

    很容易记住什么 isna() 是因为当你看到numpy方法的时候 np.isnan() NaN 价值观。在pandas中还有其他类似的方法名,比如 dropna() , fillna() 它可以处理丢失的值,并且帮助您轻松地记住。