Apparently incorrect error when going out of bounds on a dataframe

julia> df=DataFrame(rand(3,3))
3×3 DataFrame
│ Row │ x1       │ x2       │ x3       │
│     │ Float64  │ Float64  │ Float64  │
├─────┼──────────┼──────────┼──────────┤
│ 1   │ 0.505311 │ 0.327654 │ 0.761537 │
│ 2   │ 0.69492  │ 0.743024 │ 0.430169 │
│ 3   │ 0.549926 │ 0.455567 │ 0.653309 │

julia> df[1,1]
0.5053108749208113

julia> df[4,1]
ERROR: BoundsError: attempt to access String
Stacktrace:
 [1] getindex(::DataFrame, ::Int64, ::Int64) at C:\Users\klaff\.julia\packages\DataFrames\S3ZFo\src\dataframe\dataframe.jl:314
 [2] top-level scope at none:0

julia>

I was confused by the “attempt to access String” part. When I look at dataframe.jl:314, it contains a different error message: throw(BoundsError("attempt to access a data frame with $(nrow(df)) " * "rows at index $row_ind")), which would make much more sense.

Is this behavior repeatable for others or do I have something locally messed up?

I think this is fixed in the latest release, see here.

2 Likes

Thank you! Somehow I was stuck on an old version of DataFrames.