bkamins / Julia-DataFrames-Tutorial

A tutorial on Julia DataFrames package
MIT License
531 stars 119 forks source link

Deprecation in 05_columns #14

Closed sbacelar closed 5 years ago

sbacelar commented 5 years ago

x = DataFrame(Bool, 3, 4) is deprecated. Should be x = DataFrame(Matrix{Bool}(undef,3,4))

bkamins commented 5 years ago

either what you write or:

DataFrame(AbstractVector[Vector{Bool}(undef, 3) for _ in 1:4])

which will be a bit faster.

Actually - can you please comment why do you need DataFrame(Bool, 3, 4). The question about this deprecation keeps coming back. Maybe we should keep it. We deprecated it, because we thought it is not needed. Creating an uninitialized DataFrame and later filling it is not efficient. It is better to push! rows to data frame or add columns consecutively. Can you please share what is your use case?

sbacelar commented 5 years ago

Well, I was only following the DataFrame tutorial when I received the following warning :

┌ Warning: `DataFrame(t::Type, nrows::Integer, ncols::Integer)` is deprecated, use `DataFrame(Matrix{t}(undef, nrows, ncols))` instead.
│   caller = top-level scope at In[2]:1
└ @ Core In[2]:1

I simply tried to code in conformity.

bkamins commented 5 years ago

Is this one of the curated tutorials, namely:

https://github.com/bkamins/Julia-DataFrames-Tutorial

or

https://juliadata.github.io/DataFrames.jl/stable/

If yes - please report, as we have to fix it. If not - probably we can contact the maintainer of the other tutorial to suggest an update.

Anyway - since you have asked - do you then personally feel such a constructor would be useful to have?

sbacelar commented 5 years ago

Sorry, I was using a non-synced fork from [https://github.com/bkamins/Julia-DataFrames-Tutorial]() where I found the above-cited warning. Now I am using a newer version of the tutorial. I am not an expert but I agree with you that creating an uninitialized DataFrame and later filling it is not efficient. I remember doing in R something like df <- NULL before doing anything else.