时间:2023-01-01 12:42:25 | 栏目:Python代码 | 点击:次
如下所示:
###方法1:用shift函数,不用通过循环 import pandas as pd import numpy as np import matplotlib as plt df = pd.DataFrame(np.random.randn(6,4),index=dates,columns=list('ABCD')) df['diff'] = df['A'] - df['A'].shift(1)