Determining the cumulative maximum of a column

前端 未结 1 1467
悲&欢浪女
悲&欢浪女 2020-12-12 06:55

I am trying the following code

df = pd.DataFrame([[23, 52], [36, 49], [52, 61], [75, 82], [97, 12]], columns=[\'A\', \'B\'])
df[\'C\'] = np.where(df[\'A\'] &         


        
相关标签:
1条回答
  • 2020-12-12 07:29

    you need cummax:

    df['C'] = df.A.cummax()
    
    0 讨论(0)
提交回复
热议问题