# BoundsError: attempt to access "attempt to access a data frame with 6 columns at index 14"

**URL:** https://discourse.julialang.org/t/boundserror-attempt-to-access-attempt-to-access-a-data-frame-with-6-columns-at-index-14/30546
**Category:** New to Julia
**Created:** [October 31, 2019, 4:15pm UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-attempt-to-access-a-data-frame-with-6-columns-at-index-14/30546 "2019-10-31T16:15:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Irene\_Marchand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/irene_marchand/32/8758_2.png) [@Irene\_Marchand](https://discourse.julialang.org/u/Irene_Marchand)
#### Post date: [October 31, 2019, 4:15pm UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-attempt-to-access-a-data-frame-with-6-columns-at-index-14/30546/1 "2019-10-31T16:15:04Z")

</div>

Hello everyone,

I am a little confused and I need your help because I am not able to understand my error.  
I wrote this two functions but for both of them I have the following error: BoundsError: attempt to access “attempt to access a data frame with 6 columns at index 14”.  
My dataframe is a scv file

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/a/9a184a539c781c9688eea5d60b7da6f0a581aa21.png)

I would be really grateful if someone could help me to understand this error and what to do about it.  
Thank you!

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [October 31, 2019, 4:45pm UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-attempt-to-access-a-data-frame-with-6-columns-at-index-14/30546/2 "2019-10-31T16:45:40Z")

</div>

The `size` function returns a tuple containing the number of dimensions of each index of an array, or, in this case, a `DataFrame`. Since you seem to be attempting to iterate over the columns of the dataframe, what you are looking for is `size(df,2)` which gives the number of dimensions of the second index, in this case the number of columns. Note that this will return an integer, so what you want is `1:size(df,2)` which gives all integers in that range (inclusive).

Lastly, I recommend using function signatures like

```julia
function normalize(df::AbstractDataFrame, startcols=2)

end

```

This would allow your functions to operate on any `AbstractDataFrame`, not just `DataFrame` (which is a concrete sub-type of `AbstractDataFrame`). Probably not important here, but it’s good to get in the habit of writing generic code, since the ease of writing generic code is one of the best aspects of Julia. In general, you shouldn’t necessarily feel compelled to include types in function signatures. There is no performance penalty to omitting them.

---

<div class="post-metadata">

### Author: ![Irene\_Marchand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/irene_marchand/32/8758_2.png) [@Irene\_Marchand](https://discourse.julialang.org/u/Irene_Marchand)
#### Post date: [November 1, 2019, 12:39pm UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-attempt-to-access-a-data-frame-with-6-columns-at-index-14/30546/3 "2019-11-01T12:39:07Z")

</div>

Thank you very much for your fast and very complete reply. I’ll try this immediately!  
Thank you again.

---

<div class="post-metadata">

### Author: ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)
#### Post date: [November 1, 2019, 2:11pm UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-attempt-to-access-a-data-frame-with-6-columns-at-index-14/30546/4 "2019-11-01T14:11:52Z")

</div>

Yes, to second what was mentioned above, you don’t need type signatures to necessarily improve performance although if it helps you understand the types of inputs better (say, you’re coming back to the same code after a year), you can include type signatures for clarity.
