Converting (combined) Pooled DataFrame to Matrix

Searchable documentation suggests that a way to convert a DataFrame to a Matrix is just


Previously, this worked with (combined) Pooled DataFrames
but something seems to have changed in a recent update, and the above no longer seems to work.

Now, when I try to run this, I get the error

MethodError: Cannot `convert` an object of type 
  DataFrame to an object of type 
  Matrix{T} where T
Closest candidates are:
  convert(::Type{Matrix{T} where T}, ::PooledArrays.PooledMatrix{T, R, RA} where RA) where {T, R} at /home/davide/.julia/packages/PooledArrays/jKDrZ/src/PooledArrays.jl:506
  convert(::Type{Matrix{T} where T}, ::DataValues.DataValueMatrix{T}) where T at /home/davide/.julia/packages/DataValues/N7oeL/src/array/primitives.jl:287
  convert(::Type{Matrix{T} where T}, ::DataValues.DataValueMatrix{T}, ::Any) where T at /home/davide/.julia/packages/DataValues/N7oeL/src/array/primitives.jl:319

Obviously some new specification must be required.

Can anyone help me please? This must be a recent change because the code worked before I updated.


This is not supported currently. Where have you found this recommendation?

You should just use Matrix constructor, so write Matrix(df).

1 Like

Thanks. The reference was

Yours was one of the suggestions as well. The last time I tried it, the ‘convert’ version worked, but now it fails (after an update).

See Remove unnecessary convert methods · Issue #2666 · JuliaData/DataFrames.jl · GitHub for the reasoning behind removing these (in short: improving both consistency with Julia Base and compilation latency).

More precisely, it was the one most voted.

I do not see me answering this question. AFACT @pszufe answered this question pointing to a constructor approach.

1 Like

That is what the OP meant :slight_smile:

1 Like

Anyway, it worked - thanks all!

1 Like

Ah - now I understand what OP meant. Thank you for caring to explain. We really care to clean-up outdated recommendations on the web. That is why I have investigated.

1 Like