I am new to Julia. I want to handle missing data in Julia using replace
function. but I got this error: AbstractDataFrame is not iterable. Use eachrow(df) to get a row iterator or eachcol(df) to get a column iterator
Here is my code. it will show the time consumption for imputing missing data
using Missings
using DataFrames
df = DataFrame(i=1:6, x=[5, missing, 4, missing, 2,1])
replace!(df.x, missing=> 10)
@time sum(skipmissing(df))
I don't know how to correct this error. Did I miss something in my code?
You need to provide the column name where you want to calculate the sum:
sum(skipmissing(df.x))
If you want to calculate the sum over the entire table you can do:
sum(sum.(skipmissing.(eachcol(df))))