Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of view kwarg in Tables.subset #297

Open
bkamins opened this issue Sep 16, 2022 · 1 comment
Open

Incorrect handling of view kwarg in Tables.subset #297

bkamins opened this issue Sep 16, 2022 · 1 comment

Comments

@bkamins
Copy link
Member

bkamins commented Sep 16, 2022

Example:

julia> nt = (a=[1,2,3], b=[4,5,6])
(a = [1, 2, 3], b = [4, 5, 6])

julia> x2 = Tables.subset(nt, 1, view=true)
(a = 1, b = 4)

julia> x1 = Tables.subset(nt, 1, view=false)
(a = 1, b = 4)

julia> nt.a[1]=100
100

julia> x2
(a = 1, b = 4)

julia> x1
(a = 1, b = 4)

vs

julia> df = DataFrame(a=[1,2,3], b=[4,5,6])
3×2 DataFrame
 Row │ a      b
     │ Int64  Int64
─────┼──────────────
   1 │     1      4
   2 │     2      5
   3 │     3      6

julia> x1 = Tables.subset(df, 1, view=false)
Tables.ColumnsRow{DataFrames.DataFrameColumns{DataFrame}}: (a = 1, b = 4)

julia> x2 = Tables.subset(df, 1, view=true)
Tables.ColumnsRow{DataFrames.DataFrameColumns{DataFrame}}: (a = 1, b = 4)

julia> df.a[1] = 100
100

julia> x1
Tables.ColumnsRow{DataFrames.DataFrameColumns{DataFrame}}: (a = 100, b = 4)

julia> x2
Tables.ColumnsRow{DataFrames.DataFrameColumns{DataFrame}}: (a = 100, b = 4)

So we see that view kwarg when returning row is not respected and is not handled consistently.

@bkamins
Copy link
Member Author

bkamins commented Sep 16, 2022

See JuliaData/DataFrames.jl#3158 for what I believe is a concrete implementation of Tables.subset (an example for data frame)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant