I’ve wasted half a day in frustration just trying to clean up some simple data. Basically, it’s a bunch of numbers as strings that I’ve bought into a data frame and now just want to remove missing values, spaces, remove commas in the numbers, and convert all these columns to integers.
By the time I’ve received these columns into the dataframe Julia has created the following column types:
Vector{Union{Missing, String15}}
Vector{Union{Missing, String15}}
PooledArrays.PooledVector{Union{Missing, String15}, UInt32, Vector{UInt32}}
PooledArrays.PooledVector{Union{Missing, String15}, UInt32, Vector{UInt32}}
PooledArrays.PooledVector{Union{Missing, String15}, UInt32, Vector{UInt32}}
PooledArrays.PooledVector{Union{Missing, String15}, UInt32, Vector{UInt32}}
Vector{Union{Missing, String15}}
Vector{Union{Missing, String15}}
Vector{Union{Missing, String15}}
Vector{Union{Missing, String15}}
Vector{Union{Missing, String15}}
Vector{Union{Missing, String15}}
PooledArrays.PooledVector{Union{Missing, String7}, UInt32, Vector{UInt32}}
PooledArrays.PooledVector{Union{Missing, String7}, UInt32, Vector{UInt32}}
PooledArrays.PooledVector{Union{Missing, String15}, UInt32, Vector{UInt32}}
PooledArrays.PooledVector{Union{Missing, String15}, UInt32, Vector{UInt32}}
Vector{Union{Missing, Int64}}
But they’re all just strings of numbers, so it should not be hard.
I have the following code:
for (name, col) in pairs(eachcol(df))
coalesce.(df[:,name],0)
replace.(df[:,name], "," => "")
end
but it’s generating the following error when it hits the replace line:
MethodError: no method matching similar(::Int64, ::Type{Any})
Can anyone help me?