# Is there an equivalent of eachindex() for DataFrames?

**URL:** https://discourse.julialang.org/t/is-there-an-equivalent-of-eachindex-for-dataframes/88945
**Category:** General Usage
**Tags:** question, dataframes, type-stability
**Created:** [October 19, 2022, 7:17am UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-eachindex-for-dataframes/88945 "2022-10-19T07:17:21Z")
**Posts on this page:** 1
**Showing post:** 8

<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: [October 20, 2022, 7:39am UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-eachindex-for-dataframes/88945/8 "2022-10-20T07:39:58Z")

</div>

If all columns have the same type then what is enough is:

```julia
for col in eachcol(df)
    for v in col::Vector{String} # assuming this is the type of column
        ... your code
    end
end

```

of course converting to a `Matrix` or to `Tables.columntable` also will work in this case.

---

_[View the full topic](https://discourse.julialang.org/t/is-there-an-equivalent-of-eachindex-for-dataframes/88945)._
