# Converting (combined) Pooled DataFrame to Matrix

**URL:** <https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589>\
**Category:** General Usage\
**Tags:** question, dataframes, convert\
**Created:** [September 2, 2021, 4:01pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589 "2021-09-02T16:01:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)\
**Post date:** [September 2, 2021, 4:01pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/1 "2021-09-02T16:01:04Z")

</div>

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

```julia
convert(Matrix,df)

```

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

```julia
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.

Thanks

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [September 2, 2021, 4:23pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/2 "2021-09-02T16:23:46Z")

</div>

> [@compleat](#):
>
> Searchable documentation suggests

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

* * *

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

---

<div class="post-metadata">

**Author:** ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)\
**Post date:** [September 2, 2021, 4:38pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/3 "2021-09-02T16:38:11Z")

</div>

Thanks. The reference was  
[https://stackoverflow.com/questions/65392617/julia-how-to-conver-dataframe-to-array](https://stackoverflow.com/questions/65392617/julia-how-to-conver-dataframe-to-array)

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).

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [September 2, 2021, 4:54pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/4 "2021-09-02T16:54:24Z")

</div>

See [https://github.com/JuliaData/DataFrames.jl/issues/2666](https://github.com/JuliaData/DataFrames.jl/issues/2666) for the reasoning behind removing these (in short: improving both consistency with Julia Base and compilation latency).

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 2, 2021, 5:31pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/5 "2021-09-02T17:31:14Z")

</div>

> [@compleat](#):
>
> Yours was one of the suggestions as well.

More precisely, it was the one most voted.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [September 2, 2021, 7:52pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/6 "2021-09-02T19:52:17Z")

</div>

> [@rafael.guerra](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 2, 2021, 8:12pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/7 "2021-09-02T20:12:37Z")

</div>

That is what the OP meant 🙂

---

<div class="post-metadata">

**Author:** ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)\
**Post date:** [September 2, 2021, 8:14pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/8 "2021-09-02T20:14:04Z")

</div>

Anyway, it worked - thanks all!

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [September 2, 2021, 8:27pm UTC](https://discourse.julialang.org/t/converting-combined-pooled-dataframe-to-matrix/67589/9 "2021-09-02T20:27:46Z")

</div>

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.
