-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
R rolling join equivalent in Pandas #7546
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
Comments
closing as stale. pls reopen if still an issue. |
Rolling join is not
|
R newbie here. @Make42 Could you please provide short python code snippet with all steps or at least clarify step 7 because I am not sure I get it. |
@PaluchowskiMatthew: I did an example for you. Maybe you can give me some points on stackoverflow: http://stackoverflow.com/a/43539437/4533188 |
@Make42 Awesome thanks! +1 on stackoverflow |
Hi,
In R, there is a way to perform a rolling join as shown below.
library("data.table")
DT <-
data.table(
x = rep(c("a", "b", "c"), each = 3),
y = c(1, 3, 6),
v = 1:9)
setkey(DT, x, y) # Necessary for following self join.
DT[J("a", 4:6)]
DT[J("a", 4:6), roll = TRUE]
The relevant output looks like this (
J
is shorthand for self join):In Pandas, the closest that I could think of is to use Join then DataFrame,fillna(method='pad') . But this will not yield the above R rolling join result since the first 2 rows would be NA in the joined column (it starts with (a,3) and not (a,2))
I am just wondering whether there is an equivalent operation in Pandas for this?
Kind regards,
Kris
The text was updated successfully, but these errors were encountered: