Is there a function in numpy to guarantee or rather fix an array such that it is (nonstrictly) increasing along one particular axis? For example, I have the following 2D array:<
pandas offers you the df.cummax function:
pandas
df.cummax
import pandas as pd pd.DataFrame(X).cummax(axis=1).values array([[1, 2, 2, 4, 5], [0, 3, 3, 5, 5]])
It's useful to know that there's a first class function on hand in case your data is already loaded into a dataframe.