Python pandas: how to remove nan and -inf values

前端 未结 6 559
自闭症患者
自闭症患者 2020-12-02 12:10

I have the following dataframe

           time       X    Y  X_t0     X_tp0  X_t1     X_tp1  X_t2     X_tp2
0         0.002876    0   10     0       NaN   Na         


        
6条回答
  •  难免孤独
    2020-12-02 12:56

    df.replace only replaces the first occurrence on the value and thus the error

    df = list(filter(lambda x: x!= inf, df)) would remove all occurrences of inf and then the drop function can be used

提交回复
热议问题