Julia | DataFrame | Replacing missing Values

前端 未结 4 1538
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-20 13:53

How can we replace missing values with 0.0 for a column in a DataFrame?

4条回答
  •  清酒与你
    2021-02-20 14:19

    create df with some NAs

    using DataFrames
    df = DataFrame(A = 1.0:10.0, B = 2.0:2.0:20.0)
    df[ df[:B] %2 .== 0, :A ] = NA
    

    you'll see some NA in df... we now convert them to 0.0

    df[ isna(df[:A]), :A] = 0
    

    EDIT=NaNNA. Thanks @Reza

提交回复
热议问题