采用shift方法 import pandas as pd df = pd.DataFrame({‘A’:[1,2,4,4,8]}) print(df) df[‘B’]=df[‘A’].shift(1)-df[‘A’] print(df)