I have a dataframe and I want to ignore (replace by NaN) values which do not have enough non-NaN values within a rolling window. Example dataframe can be recreated the following way:

```
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
for col in df.columns:
    df.loc[df.sample(frac=0.25).index, col] = np.nan  

       A     B     C     D
0   38.0  39.0   NaN  82.0
1   44.0  47.0   NaN   NaN
2    NaN  24.0  67.0   NaN
3   96.0   NaN   NaN  68.0
4   53.0   NaN  27.0  93.0

```

I want to create a rolling window with width of 4 and for each window, I want to only keep the value if there are at least `min_periods` non-NaN values there.

I thought this would be trivial simply by using:

```
df.rolling(4, min_periods=2).apply(lambda x: x)

```

However, it seems `apply` doesn't allow such lambda functions, and a `pandas.core.base.DataError: No numeric types to aggregate` error is returned.