Compute the running (cumulative) maximum for a series in pandas

后端 未结 1 2008
轮回少年
轮回少年 2020-12-03 19:34

Given:

d = {
    \'High\': [954,
             953,
             952,
             955,
             956,
                      


        
相关标签:
1条回答
  • 2020-12-03 20:01

    Use cummax

    df.High.cummax()
    
    0    954
    1    954
    2    954
    3    955
    4    956
    5    956
    6    956
    7    956
    Name: High, dtype: int64
    

    df['Max'] = df.High.cummax()
    df
    

    0 讨论(0)
提交回复
热议问题