Max of min windows

Suppose we have a series of numbers, num_series. We are interested in the maximum value of the minimum of every overlapping window of size window.

For example, if num_series is defined as follows, and window = 3

import pandas as pd

num_series = pd.Series([1, 2, 3, 4, 1, 2])

Then the minimum of every window of size three would be [1, 2, 1, 1] and the maximum of those minimums is 2.

Task: Write a function, max_of_min_windows(num_series, window) which takes in the Series, num_series and window size window and returns the maximum of the minimum values for each window.

Example Input

Code to generate input

df = pd.Series([1, 2, 3, 4, 1, 2])
window = 3


Table generated

0
0 1
1 2
2 3
3 4
4 1
5 2

Example Output

2.0