-
Notifications
You must be signed in to change notification settings - Fork 370
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
Convience methods for getproperty
and setproperty
in DataFrames with new ownership rules
#1753
Comments
I am done reading it 😄. Thank you for the input. This is indeed a hard nut to crack. For an alternative to For an alternative to
An alternative to
I am giving here my loose thoughts as I am still not sure what would be best. Also I would explore macros rather in the DataFramesMeta.jl package. |
I have found a hack!
This might be too ugly to show to users though. |
This is nice indeed. |
We can define the following:
But the evaluated symbol is a good point. Just to be clear, there is no way to have a function like
That has the same symmetry as Another soluttion, that I like a lot, is having an object where you can overload
|
|
Also removal of EDIT I am writing it as I keep answering to different questions in several places and people keep writing |
I do not understand what is wrong with It matches well with how views work in the rest of the language. |
I agree with what @oxinabox says, and I was voting for removing |
@bkamins you are right, this my be premature considering we haven't even started deprecating You correctly note that this issue is really about the planned deprecation of Here is my reasoning regarding
|
To be clear neither We are considering to remove
(of course adding |
Riiiight, ok, i hadn't considered the LHS problem.
OTOH, my life would be easier if we left that getindex and setindex exactly as they are |
That is my point - we have consistency against convenience issue here. |
An available syntax is |
|
Woah, that is so crazy, it might just work. |
So might go this way:
|
Actually its not, from a DataFrames as there own thing, the raw column vector As such it might be that
One factor worth considering is: |
I don't think we should really be concerned about this since it's a corner case. I'd tend to go with the most consistent solution. We could even throw an error for now.
If we return a My argument to return a |
So here is my point. We deprecate
Note that So for example in the future:
should do exactly the same what:
does currently. EDIT |
The only drawback is that EDIT The only problem will be current calls like |
We could always throw an error for Perhaps though for now, we don't touch |
This is what we do with the only change that in #1742 currently calling |
It would be cool to see how confused people are about We could emphasize that There is still some semblance of logic because our goal is just to have a Would it make sense to have a feature request to Julia to add some sort of |
There's no way you'll convince me of doing this madness. We're not Pandas! :-p Also that would mean there's no short syntax for
What do you mean? |
FWIW:
|
Just to expand on Also |
While we are unclear what to do with
E.g. here |
@pdeffebach can this be closed given the new rules in https://github.com/JuliaData/DataFrames.jl/blob/master/docs/src/lib/indexing.md? |
Closing this - we have |
I have remarked about this on slack and in #1695. On @nalimilan's suggestion I am posting an issue to discuss how we can make
df.col
easier with non-literals.Motivation: With #1695 (mostly) concluded, we will likely have the following two ways to get a single column from a DataFrame
df[:, :col]
: a copydf.col
a non-copy.df[:col]
: deprecated.I really like
df.col
syntax. I find it intuitive and requires little typing. However it only works with the actual literalcol
. If you have a variablex
representing the symbol:col
, you cannot dodf.x
to get the column:col
. You also can't just dodf[:, x]
because that has different behavior -- a copy rather than the exact same vector.I want to find a syntax for
df.col = f.(df.col)
where you use the variable
x
to represent:col
.Alternative solutions for
getproperty
:getproperty(df, x)
to have the same behavior asdf.col
.select!(df, x)
to have the same behavior.Alternative solutions for `setproperty!:
setcol!(df, x, v)
will work. However I don't like it because now you have to worry about an extra parentheses.Is complicated enough as is, without putting it in
setcol!(df, x, ...)
.Finally I like the symmetry of
getproperty
andsetproperty
looking the same.df.col = f.(df.col)
is elegant.Solutions:
Ideally:
df.$x = v
would be valid Julia syntax, where the$
escapes whatever is following it.struct
and overloadgetproperty(df, s::ColumnSelector)
. This is not possible, however, because Julia doesn't evaluate the expression after the dot at all. This doesn't work.Pragmatically:
I'm at a bit of a dead end in terms of ideas for this. But I do think it's important. The average scientist codes in global scope, and we aren't going to get them to put things in functions if they have to re-write all their code in a less intuitive way in order to do that.
Thanks for reading my rant.
The text was updated successfully, but these errors were encountered: