def _apply_window(self, mean=True, **kwargs):
window = self._prep_window(**kwargs)<EOL>center = self.center<EOL>blocks, obj, index = self._create_blocks()<EOL>results = []<EOL>for b in blocks:<EOL><INDENT>try:<EOL><INDENT>values = self._prep_values(b.values)<EOL><DEDENT>except TypeError:<EOL><INDENT>results.append(b.values.copy())<EOL>continue<EOL><DEDENT>if values.size == <NUM_LIT:0>:<EOL><INDENT>results.append(values.copy())<EOL>continue<EOL><DEDENT>offset = _offset(window, center)<EOL>additional_nans = np.array([np.NaN] * offset)<EOL>def f(arg, *args, **kwargs):<EOL><INDENT>minp = _use_window(self.min_periods, len(window))<EOL>return libwindow.roll_window(np.concatenate((arg,<EOL>additional_nans))<EOL>if center else arg, window, minp,<EOL>avg=mean)<EOL><DEDENT>result = np.apply_along_axis(f, self.axis, values)<EOL>if center:<EOL><INDENT>result = self._center_window(result, window)<EOL><DEDENT>results.append(result)<EOL><DEDENT>return self._wrap_results(results, blocks, obj)<EOL>
Applies a moving window of type ``window_type`` on the data.

Parameters
----------
mean : bool, default True
    If True computes weighted mean, else weighted sum

Returns
-------
y : same type as input argument