-
Notifications
You must be signed in to change notification settings - Fork 368
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
Automatically fill in select
and combine
for scalars?
#2162
Comments
This was intentional because
However, I have also been considering if we should not add this as a third case of automatic broadcasting that is allowed (other two are in There are special cases of several types that would be excluded for |
Thanks for this. I understand more the reasoning. If you have one function returning a scalar and another returns a vector, there is ambiguiity. I agree that I'm not sure about SemVer but if this is a post-1.0 thing we can wait. |
It is not hard to add, the question is if we want to add it.
There is a kind of "defensive" ambiguity now (i.e. we do not implicitly broadcast). But we could without a problem, i.e. all functions would have to return either one element or vectors of the same length (just like in broadcasting). We would just have to check if it would not have significant consequences for the performance of Again just two caveats here about corner cases (so that we do not forget them when we come back to this issue):
|
Yes it would make sense to recycle scalars at least (and probably It shouldn't have a big impact on performance of existing uses since we specialize the function on the column types, so any type checks we add will be resolved statically by the compiler. But the implementation will be a bit tricky as cases mixing arrays and scalars will have to be identified and scalars promoted to arrays of the correct length before calling the method that operates on arrays (simple implementation: a smarter one would avoid allocating intermediate arrays but I'm not sure how complex it would be). |
select
for scalars?select
and combine
for scalars?
Just some additional notes:
But I guess we can leave adding this in |
If this is the easiest way to go, then I'm for it. But broadcasting
|
It is not easiest, but it is a consistent way to go 😄.
It would keep the names and there is no ambiguity here. We have clear rules how we perform pseudo-broadcasting in DataFrames.jl
The whole point of this issue is to start allowing this if I understand things correctly. Right? |
Well, I didn't think about "mixing" per-se. Just filling in scalars for one function call.
You mean make a column of |
This comment has been minimized.
This comment has been minimized.
No, I mean that named tuple
This was heavily discussed and the conclusion was that splatting by default is better because:
Still, we want to provide that option. We just need a good name for the wrapper. |
Yes this is great.
Sorry! that comment means to go in #2161. Will repost. |
More thoughts from this discourse thread.
In Stata,
would spread the argument for you, creating a full column of just
mean(x)
I also seem to remember that DataFramesMeta used to have this behavior, but now it throws an error.
The text was updated successfully, but these errors were encountered: