将滚动应用于一系列列表

时间:2017-10-16 19:41:18

标签: python pandas series rolling-computation

假设你有一些代码:

def test(x):
    # some function that operates on a list of lists
    # and returns a value

import pandas as pd
data = pd.Series([1,2,3], [4,5,6], [7,8,9])
x = data.rolling(2).apply(lambda x: test(x))
print(x)

运行上述代码后,x始终等于data。就好像永远不会应用滚动功能一样。

如何将这样的滚动(或扩展)功能应用于Pandas系列?

0 个答案:

没有答案
相关问题