I want monotonic trend of a variables. Data looks like:
Output is required in the form of:
I have tried to iterate over rows using apply but got no luck. I have also tried is_monotonic_increasing and is_monotonic_decreasing from pandas.
Thanks in advance for your help.


pd.Series.is_monotonic_decreasingcan work for your case.I would first
pivotthe dataframe in order to get each varaible in a column, then for each column dropnans (otherwiseis_monotonic_decreasingwill always returnFalse), apply bothis_monotonic_decreasingandis_monotonic_increasingand collect the results: