I have a DataFrame
with Int64
columns:
using DataFrames
df = DataFrame(a=1:3,b=4:6,c=["a","b","c"])
3×2 DataFrame
Row │ a b c
│ Int64 Int64 String
─────┼──────────────────────
1 │ 1 4 a
2 │ 2 5 b
3 │ 3 6 c
Now, I want to change the column types to Float64
. I know that I can do something like...
using DataFramesMeta, Chain
@chain df begin
@transform!(:a = Float64.(:a),
:b = Float64.(:b))
end
or
df.a = Float64.(df.a)
df.b = Float64.(df.b)
But how can I change all columns of type Int64
to Float64
. Columns of other types should stay as they are.
(As you might guess from the example above I like the combination of Chain
and DataFramesMeta
, but of course all answers are more than welcome.)