How to replace NaN values by Zeroes in a column of a Pandas Dataframe?

后端 未结 13 1650
无人共我
无人共我 2020-11-22 01:37

I have a Pandas Dataframe as below:

      itm Date                  Amount 
67    420 2012-09-30 00:00:00   65211
68    421 2012-09-09 00:00:00   29424
69             


        
13条回答
  •  野性不改
    2020-11-22 01:58

    Considering the particular column Amount in the above table is of integer type. The following would be a solution :

    df['Amount'] = df.Amount.fillna(0).astype(int)
    

    Similarly, you can fill it with various data types like float, str and so on.

    In particular, I would consider datatype to compare various values of the same column.

提交回复
热议问题