# DataFrame eltypes error without using eltypes

**URL:** https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473
**Category:** General Usage
**Tags:** cluster, dataframes, eltype
**Created:** [May 19, 2021, 10:12pm UTC](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473 "2021-05-19T22:12:09Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![seulberg1](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@seulberg1](https://discourse.julialang.org/u/seulberg1)
#### Post date: [May 19, 2021, 10:12pm UTC](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473/1 "2021-05-19T22:12:09Z")

</div>

Hello All

I am trying to run Julia code on a Linux cluster that works flawlessly on my personal machine. The MWE that fails for me:

```julia
using Pkg
Pkg.activate("/home/path/JuliaEnv/") #Activate Environment
using DataFrames
println("BeginTest")
dummyDF = DataFrame([String],["String"],1)
println("EndTest")

```

fails with:

```julia
Activating environment at `~/path/JuliaEnv/Project.toml`
ERROR: LoadError: ArgumentError: `DataFrame` constructor with passed eltypes is not supported. Pass explicitly created columns to a `DataFrame` constructor instead.
Stacktrace:
[1] DataFrame(::Array{DataType,1}, ::Array{String,1}, ::Int64; makeunique::Bool) at path/.julia/packages/DataFrames/nxjiD/src/dataframe/dataframe.jl:380
[2] DataFrame(::Array{DataType,1}, ::Array{String,1}, ::Int64) at path/.julia/packages/DataFrames/nxjiD/src/dataframe/dataframe.jl:380
[3] top-level scope at file.jl:7
in expression starting at file.jl:7
BeginTest

```

I am not even using the eltypes command here and it fails. Ironically, the full script uses `DataFrame(XLSX.readtable("ExcelFile.xlsx", "Sheet1"; infer_eltypes=true)...)` at some previous stage without any problems, but it somehow fails to construct any DataFrames (which I need). This is on Julia 1.5.4, which I have reinstalled, I also tried 1.6.1, deleting various folders in Julia, recompiling, reinstating the environment etc, nothing worked.

Any help on how to resolve this is much appreciated, I don’t want to rewrite everything in Python just so I can use the cluster…

---

<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: [May 20, 2021, 5:06am UTC](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473/2 "2021-05-20T05:06:45Z")

</div>

I forget which constructors are supported in which version of DataFrames, but this looks to me like the versions of DataFrames on the cluster and your personnel machine are different?

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [May 20, 2021, 5:49am UTC](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473/3 "2021-05-20T05:49:50Z")

</div>

Indeed `DataFrame([Int, Int], [:a, :b])` or similar (first a list of types, then a list of names) was removed in recent versions. Instead you can do `DataFrame(a=Int[], b=Int[])`, or if the names and types are variables you can do something like `DataFrame(colnames .=> [type[] for type in types])`.

Can you give the code at line 7 of `file.jl`?

---

<div class="post-metadata">

### Author: ![seulberg1](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@seulberg1](https://discourse.julialang.org/u/seulberg1)
#### Post date: [May 20, 2021, 3:15pm UTC](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473/4 "2021-05-20T15:15:28Z")

</div>

Ah yes - I think the error message is misleading, but indeed this way of constructing DataFrames seems to not be supported with this DataFrames version.

---

<div class="post-metadata">

### Author: ![seulberg1](https://avatars.discourse-cdn.com/v4/letter/s/e480ec/32.png) [@seulberg1](https://discourse.julialang.org/u/seulberg1)
#### Post date: [May 20, 2021, 3:16pm UTC](https://discourse.julialang.org/t/dataframe-eltypes-error-without-using-eltypes/61473/5 "2021-05-20T15:16:44Z")

</div>

Yes using this construction method did the trick - line 7 is actually the DataFrame([String],[“String”],1) line from the MWE, but I omitted some commented out lines causing the discrepency between error message and MWE.
