Skip to content
Advertisement

Taking the min value of N last days

I have this data frame:

JavaScript

I want to show the min value of n last days (say, n = 4), using Date column, excluding the value of current day.

A similar solution has provided by jezrael. (That one calculates the mean, and not min.)

Expected result:

JavaScript

Advertisement

Answer

Use similar solution like @Chris with custom lambda function in GroupBy.apply and last join to original by DataFrame.join:

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement