The warning tells you exactly what to do:
C:\Users\ngudat>julia --depwarn=yes
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.6.0-beta1.0 (2021-01-08)
_/ |\__'_|_|_|\__'_| | release-1.6/b84990e1ac (fork: 107 commits, 78 days)
|__/ |
julia> using DataFrames
julia> DataFrame(rand(3, 3))
β Warning: `DataFrame(columns::AbstractMatrix)` is deprecated, use `DataFrame(columns, :auto)` instead.
β caller = ip:0x0
β @ Core :-1
3Γ3 DataFrame
Row β x1 x2 x3
β Float64 Float64 Float64
ββββββΌββββββββββββββββββββββββββββββ
1 β 0.622345 0.212857 0.450722
2 β 0.964056 0.592422 0.404494
3 β 0.779371 0.621828 0.825098
julia> DataFrame(rand(3, 3), :auto)
3Γ3 DataFrame
Row β x1 x2 x3
β Float64 Float64 Float64
ββββββΌββββββββββββββββββββββββββββββ
1 β 0.4546 0.737729 0.922938
2 β 0.656548 0.978919 0.47053
3 β 0.372329 0.129186 0.134449
What has been deprecated is passing a matrix (more precisely, an object whose type is a subtype of AbstractMatrix
) by itself to the DataFrame
constructor, without specifying column names. I.e. you could have done, without warning:
julia> DataFrame(rand(3, 3), [:a, :b, :c])
3Γ3 DataFrame
Row β a b c
β Float64 Float64 Float64
ββββββΌβββββββββββββββββββββββββββββββ
1 β 0.740213 0.76078 0.215738
2 β 0.680955 0.0326686 0.122183
3 β 0.652353 0.590362 0.299639
Where Iβve passed in the column names a
, b
, and c
. In older versions of DataFrames, if you didnβt specify column names, by default the constructor would assign x1
through to xN
where N
is the number of columns in your matrix. The issue you linked discusses why this was not ideal, and why the change was made, but I donβt think itβs necessary to follow all of that. All you need to know is that to get the old behaviour back, you change your code from DataFrame(my_matrix)
to DataFrame(my_matrix, :auto)
as explained in the deprecation warning.
To address another part of your question, you say you donβt use ::
anywhere, and it seems thereβs a bit of a misunderstanding here about how types and dispatch work in Julia. When I define a function f
with a method f(x::Float64)
, that means "call this method of f
whenever the type of the variable x
is Float64
. That means, this method will get called if I do f(1.0)
, because typeof(1.0) == Float64
. Thereβs no need for me as the user who calls f
to annotate the call in some way (i.e. do f(1.0::Float64)
) - Juliaβs type inference will work out that 1.0
has the type Float64
and therefore call the correct method.
I strongly encourage you to read the relevant sections of the manual on Types and Methods, as multiple dispatch is arguably the single most important feature of Julia. Given that youβve been around for a while and seem to be in it for the long haul with Julia developing a better understanding of this should pay off nicely in future