-
Notifications
You must be signed in to change notification settings - Fork 580
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
希望ref函数中参数n支持序列值 #54
Comments
I'm facing the same issue. Please add this support. |
def REF(S, N=1): # 对序列整体下移动N,返回序列(shift后会产生NAN)
if isinstance(N, (int, float)):
return pd.Series(S).shift(N).values
else:
res = np.repeat(np.nan, len(S))
for i in range(len(S)):
if (not np.isnan(N[i])):
res[i] = S[N[i]]
return res |
Does not seem working for me. |
try this def REF(S, N=1): # 对序列整体下移动N,返回序列(shift后会产生NAN)
if isinstance(N, (int, float)):
return pd.Series(S).shift(N).values
else:
res = np.repeat(np.nan, len(S))
for i in range(len(S)):
if (not np.isnan(N[i])):
res[i] = pd.Series(S).shift(N[i])[i]
return res
S=[0,1,2,3,4,5]
N = [1,2,2,3,3,1]
res = REF(S,N)
print(res)
# will print [nan nan 0. 0. 1. 4.] |
Excellent! It works! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: