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

Surprising setindex/setproperty behaviour #1815

Closed
nickrobinson251 opened this issue May 20, 2019 · 2 comments
Closed

Surprising setindex/setproperty behaviour #1815

nickrobinson251 opened this issue May 20, 2019 · 2 comments

Comments

@nickrobinson251
Copy link

Here's a surprising result: df.col = 1 and df[:col] = 1 broadcast i.e. act like .= 1 - which is inconsistent with df.col returning the underlying vector.

Example:

julia> df = DataFrame(:a => 1:10, :z => 1:10);

julia> df.a
10-element Array{Int64,1}:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10

julia> b = collect(1:10);

julia> df.a == b
true

julia> df.a = 1;

julia> df.a
10-element Array{Int64,1}:
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1

julia> b = 1;

julia> b
1

julia> df.a == b
false
@bkamins
Copy link
Member

bkamins commented May 20, 2019

This will be fixed soon. See #1806 and #1804 for first steps towards that. The design is not simple though.

@bkamins
Copy link
Member

bkamins commented Jul 12, 2019

See the new target rules here: https://github.com/JuliaData/DataFrames.jl/blob/master/docs/src/lib/indexing.md

They should be consistent and work as expected (we need another release cycle to get there).

I am closing this PR, but feel free to reopen if you have more comments.

@bkamins bkamins closed this as completed Jul 12, 2019
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

2 participants