# Getting a strange error when trying to join list of DataFrames, what could this be?

**URL:** <https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997>\
**Category:** General Usage\
**Created:** [June 8, 2020, 2:30pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997 "2020-06-08T14:30:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Post date:** [June 8, 2020, 2:30pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997/1 "2020-06-08T14:30:51Z")

</div>

Hi how’s it going?

I’m trying to join a list of DataFrames on a unique column, but it won’t even let me set a single one of those DataFrames to a variable and instead gives me this error.

“AbstractDataFrame is not iterable. Use eachrow(df) to get a row iterator or eachcol(df) to get a column iterator”

I’ve never had this issue in the past with Julia and the same code has worked for months.

Thanks

---

<div class="post-metadata">

**Author:** ![josephmarturano](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@josephmarturano](https://discourse.julialang.org/u/josephmarturano)\
**Post date:** [June 8, 2020, 2:45pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997/2 "2020-06-08T14:45:37Z")

</div>

The most recent update to DataFrames.jl changed the join API. Did you upgrade DataFrames.jl to 0.21?

If so, [this page](https://juliadata.github.io/DataFrames.jl/v0.21/man/joins/) shows the new joining functions.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 8, 2020, 3:11pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997/3 "2020-06-08T15:11:08Z")

</div>

Can you post a MWE?

---

<div class="post-metadata">

**Author:** ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Post date:** [June 8, 2020, 4:31pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997/4 "2020-06-08T16:31:48Z")

</div>

```julia
    cols = []
    for val in list_of_stuff
        greater_than_zero = filter(row -> row[val]>0,d)
        tx_sum = by(greater_than_zero, :identifier, Symbol(val) => sum)
        tx_mean = by(greater_than_zero, :identifier, Symbol(val) => mean)
        local_cols = [tx_sum,tx_mean]
        
        for df in local_cols
            push!(cols,df)
        end
    end
    
    total_df = cols[1]

    for i = 2:length(cols)
        total_df = join(total_df,cols[i],on = :identifier,makeunique=true,kind = :outer)
    end

AbstractDataFrame is not iterable. Use eachrow(df) to get a row iterator or eachcol(df) to get a column iterator

Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] iterate(::DataFrame) at /home/shonbutani/.julia/packages/DataFrames/kwVTY/src/abstractdataframe/iteration.jl:23
 [3] indexed_iterate(::DataFrame, ::Int64) at ./tuple.jl:84
 [4] top-level scope at In[118]:1

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 8, 2020, 4:36pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997/5 "2020-06-08T16:36:47Z")

</div>

Note that this is not an MWE. An MWE is copy-pasteable and doesn’t contain objects defined outside the code sample.

Can you confirm that you get an error for the following?

```julia
julia> cols = [DataFrame(a = [1, 2, 3], b = rand(3)) for i in 1:10];

julia> let total_df = cols[1]
       for i in 2:length(cols)
           total_df = join(total_df, cols[i], on = :a, kind = :outer, makeunique = true)
       end
       total_df
       end

```

---

<div class="post-metadata">

**Author:** ![Julia1](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@Julia1](https://discourse.julialang.org/u/Julia1)\
**Post date:** [June 8, 2020, 4:42pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997/6 "2020-06-08T16:42:14Z")

</div>

I don’t get an error for that code you sent. Strange. Something to do with the by() method changing the type of DataFrame?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [June 8, 2020, 4:49pm UTC](https://discourse.julialang.org/t/getting-a-strange-error-when-trying-to-join-list-of-dataframes-what-could-this-be/40997/7 "2020-06-08T16:49:38Z")

</div>

No, that is most likely not the issue.

You should try and make a MWE that we can copy and paste that reproduces the error.

Note that I can get the error by doing this:

```julia
julia> for i in DataFrame(rand(5,5))
       @show i
       end
ERROR: AbstractDataFrame is not iterable. Use eachrow(df) to get a row iterator or eachcol(df) to get a column iterator

```

So look for code that does something like that.
