-
Notifications
You must be signed in to change notification settings - Fork 50
Rework API to refer to current row with it
#122
Comments
What about using `rowNumber`?
…On Wed, May 26, 2021 at 10:27 PM Leandro ***@***.***> wrote:
Hello,
maybe I'm just missing something but is there a way to refence current row?
For example during addColumn, is there a way to know which row is being
populated at the time?
This would be useful for running sum like operations, and maybe to another
problem I'm not being able to solve, which would be "How do we create a
column that will copy the value from column A if it is not NA but copy it
from column B if it is?", I know this is an entirely new question by itself
but knowing what row I'm populating would allow me to solve it via
workaround.
Thank you in advance!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#122>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABRB6GARLIQTLZO2MXG6VTTPVKRJANCNFSM45SZ7VAQ>
.
|
Thank you, I knew the addRowNumber method but never thought about the variable. It's not a direct solution (I may not be looking at this the right way) but since it is still an array and not a value per se, it can't easily be used. Example would be If I wanted to retrieve one value from the previous row, I can't directly use rowNumber as it is an array. The way I managed to do it was using the map() function
I'm leaving this open in case you'd like to add something to discussion (as like I said I may not be looking at this the right way). but please feel free to mark it solved as I was now able to solve my problem (using map() on the rowNumber). Thank you for your help. |
Regarding "How do we create a column that will copy the value from column A if it is not NA but copy it from column B if it is?": data.addColumn("AorB"){ it["A"].values().zip(it["B"].values()).map{ (a, b) -> a ?: b} } Regarding your example, what about In general, I struggle myself with
Clearly, this would be a major breaking change, but I wouldn't mind anything that makes it more fun/convenient to use. It would also come along with some new inconsistency in Any thoughts? |
Regarding "How do we create a column that will copy the value from column A if it is not NA but copy it from column B if it is?" I had done it with a similar approach once I realized I could use map.
Regarding the Regarding the As much as I agree that it would make it more intuitive, I have no idea how that would affect what already works, like adding a column based on a formula or array. I will try to play with this a little once I have some time too. |
I guess that would be the common intuition in kotlin. The reason why I designed the API to refer to the entire table is that this the way dplyr works in R. |
it
Hello,
maybe I'm just missing something but is there a way to reference current row?
For example during addColumn, is there a way to know which row is being populated at the time?
This would be useful for running sum like operations, and maybe to another problem I'm not being able to solve, which would be "How do we create a column that will copy the value from column A if it is not NA but copy it from column B if it is?", I know this is an entirely new question by itself but knowing what row I'm populating would allow me to solve it via workaround.
Thank you in advance!
The text was updated successfully, but these errors were encountered: