I have this problem with shifting an entire row based on a column condition if it is NaN. if column 10 is NaN, shift the entire row 3 cells to the right. initial dataframe: I come up with this solution, but the first two columns are gone somehow. df1_copy[df1_copy[10].isnull()] = df1_copy[df1_copy[10].isnull()].shift(3, axis=1) Result: Expected: Although I tried a similar method
Tag: shift
Shifting depending on different columns and begining the shift depending on changes in columns
I have a dataframe (here an example) Date UnitId ServiceDomineId Interval ServiceTime 01/01/2021 1 1 8:00 30 01/01/2021 1 1 8:30 20 01/01/2021 1 1 9:00 10 01/01/2021 2 1 8:00 50 01/01/2021 2 1 9:00 10 01/01/2021 1 2 8:30 25 01/01/2021 1 2 9:00 15 01/01/2021 1 2 9:30 30 01/01/2021 2 2 8:00 45 01/01/2021 2 2
Python : Use of the previous value generated from a function in the same function
I am trying to have a rolling average of all the highs of [‘RSIndex’] greater than 52, series will have NaN value if the first ref value is less than 52, but I want to have the previous iterated value of [‘high_r’] that the function has generated if any other ref value is less than 52. If, anyone has any