# What does "DataFrame(columns::AbstractMatrix)\` is deprecated, use \`DataFrame(columns, :auto)\`" mean?

**URL:** https://discourse.julialang.org/t/what-does-dataframe-columns-abstractmatrix-is-deprecated-use-dataframe-columns-auto-mean/55997
**Category:** General Usage
**Tags:** warning
**Created:** [February 25, 2021, 9:40am UTC](https://discourse.julialang.org/t/what-does-dataframe-columns-abstractmatrix-is-deprecated-use-dataframe-columns-auto-mean/55997 "2021-02-25T09:40:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![HelgavonLichtenstein](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgavonlichtenstein/32/5005_2.png) [@HelgavonLichtenstein](https://discourse.julialang.org/u/HelgavonLichtenstein)
#### Post date: [February 25, 2021, 9:40am UTC](https://discourse.julialang.org/t/what-does-dataframe-columns-abstractmatrix-is-deprecated-use-dataframe-columns-auto-mean/55997/1 "2021-02-25T09:40:32Z")

</div>

Hi,

I re-ran some older code and see changes have been made. I tried following the discussion for this depreciation [here](https://github.com/JuliaData/DataFrames.jl/issues/2433) but am not understanding the difference or what I need to do to update my code.

The warning shows up only once, which is normally a good thing, but now I cannot find the line which first causes the warning. I have several files that call each other and have been slowly working backwards, restarting Julia each time to locate where the warning first appears.

`

> `DataFrame(columns::AbstractMatrix)` is deprecated, use `DataFrame(columns, :auto)` instead  
> `

Could someone give me a MWE of what has changed? I don’t use `::AbstractMatrix` specifically, as in, using `::` anywhere, so I don’t understand what this represents. I also don’t understand what `:auto` represents.

Could someone also suggest a better way of finding where in the code the warning is coming from? I haven’t figured out yet how to use the debugger, but I assume this would help me a lot.

Thank you.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [February 25, 2021, 10:38am UTC](https://discourse.julialang.org/t/what-does-dataframe-columns-abstractmatrix-is-deprecated-use-dataframe-columns-auto-mean/55997/2 "2021-02-25T10:38:06Z")

</div>

The warning tells you exactly what to do:

```julia
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
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](https://docs.julialang.org/en/v1/manual/types/) and [Methods](https://docs.julialang.org/en/v1/manual/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 🙂
