Hi,

I have a Data Frame that I want to convert into an Array but Julia gives me the following error:

MethodError: Cannot `convert`

an object of type

DataFrame to an object of type

Array

I believe that there has something to do with the new version of the DataFrames package but I canβt find anything in the documentation. I would appreciate any help.

Ps. I canβt upload the data because itβs confidential but would appreciate any help

1 Like

Youβll get more help if you can reduce your problem down to a minimal example. But what you may want is passing your dataframe to the `Matrix`

constructor, which will convert it to a 2d array, possibly of an abstract type if necessary

```
julia> df = DataFrame(a=[1, 2], b=[3, 4])
2Γ2 DataFrame
Row β a b
β Int64 Int64
ββββββΌββββββββββββββ
1 β 1 3
2 β 2 4
julia> Matrix(df)
2Γ2 Matrix{Int64}:
1 3
2 4
julia> df = DataFrame(a=[1, 2], b=["some", "strings"])
2Γ2 DataFrame
Row β a b
β Int64 String
ββββββΌββββββββββββββββ
1 β 1 some
2 β 2 strings
julia> Matrix(df)
2Γ2 Matrix{Any}:
1 "some"
2 "strings"
```

1 Like