Using Python pandas, how do I create a function to calculate the proportion of rows that represent a lower value than the previous row? So in other words, I need a function to iterate through the values under a particular series column of a Pandas Data Frame and only count those values where the next row's value (under say column called 'Mileage') is less than the current row's value. Like say you have this: Mileage: row 1: 30 row 2: 20 row 3: 40 row 4: 50 row 5: 60 row 6: 55 row 7: 75
If the counter is working correctly, it would spot that row 2's value of 20 is less than row 1's value of 30 and so it would add +1 to counter (count that one).
In the example above, another row that it should count is row 6: 55 which is < than its previous row 5: 60 and so count that one.
And so the final count would be: 2.
And then I can divide that final count by total row count to get a proportion.
Thank you in advance for any help!