How to drop rows of Pandas DataFrame whose value in a certain column is NaN

前端 未结 12 1037
一生所求
一生所求 2020-11-22 00:59

I have this DataFrame and want only the records whose EPS column is not NaN:

>>> df
                 STK_ID           


        
12条回答
  •  庸人自扰
    2020-11-22 01:33

    yet another solution which uses the fact that np.nan != np.nan:

    In [149]: df.query("EPS == EPS")
    Out[149]:
                     STK_ID  EPS  cash
    STK_ID RPT_Date
    600016 20111231  600016  4.3   NaN
    601939 20111231  601939  2.5   NaN
    

提交回复
热议问题