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

Documenting the difference betwen df[!, :col] and df[:, :col] #2000

Merged
merged 6 commits into from
Nov 15, 2019
Merged

Documenting the difference betwen df[!, :col] and df[:, :col] #2000

merged 6 commits into from
Nov 15, 2019

Conversation

aminya
Copy link
Contributor

@aminya aminya commented Nov 5, 2019

Fixes #1999

@bkamins

Co-Authored-By: Bogumił Kamiński <bkamins@sgh.waw.pl>
@nalimilan
Copy link
Member

Thanks. I've made some changes, let me know what you think.

@scls19fr
Copy link

Maybe a good place to warn about the difference could be also in the warning

Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` 

which could be changed for

Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` (reference) or `df[:, col_ind]` to get a copy

when user are doing df[:column_name]

@aminya
Copy link
Contributor Author

aminya commented Nov 11, 2019

Maybe a good place to warn about the difference could be also in the warning

Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` 

which could be changed for

Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` (reference) or `df[:, col_ind]` to get a copy

when user are doing df[:column_name]

: is not deprecated. They are two different methods. The whole point of having : is familiarity with Base Arrays! Why should we deprecate such a nice syntax?

@nalimilan
Copy link
Member

I've slightly edited the wording.

: is not deprecated.

I don't think that's what @scls19fr suggested. @scls19fr Can you file a new PR? You can edit the file directly on GitHub if you want.

@scls19fr
Copy link

Absolutely @nalimilan what I'm saying is that df[:col] is deprecated and df[!, :col] or df[:, :col] should be used instead (and ! or : should be used depending if user want a reference or a copy of column data)

I've been searching for this depwarn using
https://github.com/JuliaData/DataFrames.jl/search?q=use+%60df%5B%21%2C+col_ind%5D%60&unscoped_q=use+%60df%5B%21%2C+col_ind%5D%60

but couldn't find where it's located.

@nalimilan could you point me to code where it's located?

I will submit a PR also

@scls19fr
Copy link

Hum... not so easy to add information there I thought it could be done using a simple string... but that's not the case (or at least I don't know how to provide deprecated macro an informative string)

@nalimilan
Copy link
Member

You have to replace this with a normal function which will call Base.depwarn. See examples in the file.

Copy link
Member

@bkamins bkamins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @nalimilan - can you please merge this if you are OK with the current wording?

@nalimilan nalimilan merged commit b264b19 into JuliaData:master Nov 15, 2019
@aminya aminya deleted the patch-1 branch November 16, 2019 07:38
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

Successfully merging this pull request may close these issues.

Documenting the difference betwen df[!, :col] and df[:, :col]
4 participants