Pandas: Replacing Non-numeric cells with 0

后端 未结 3 733
囚心锁ツ
囚心锁ツ 2020-12-18 08:12

I have the Pandas Dataframe in this format

0          or LIST requests
1                 us-west-2
2                 1.125e-05
3                         0
4          


        
3条回答
  •  -上瘾入骨i
    2020-12-18 08:51

    Following code can work:

    df.col =pd.to_numeric(df.col, errors ='coerce').fillna(0).astype('int')
    

提交回复
热议问题