def apply(self, f, axes=None, filter=None, do_integrity_check=False,<EOL>consolidate=True, **kwargs):
result_blocks = []<EOL>if filter is not None:<EOL><INDENT>filter_locs = set(self.items.get_indexer_for(filter))<EOL>if len(filter_locs) == len(self.items):<EOL><INDENT>filter = None<EOL><DEDENT>else:<EOL><INDENT>kwargs['<STR_LIT>'] = filter_locs<EOL><DEDENT><DEDENT>if consolidate:<EOL><INDENT>self._consolidate_inplace()<EOL><DEDENT>if f == '<STR_LIT>':<EOL><INDENT>align_copy = True<EOL>if kwargs.get('<STR_LIT>', True):<EOL><INDENT>align_keys = ['<STR_LIT>', '<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>align_keys = ['<STR_LIT>']<EOL><DEDENT><DEDENT>elif f == '<STR_LIT>':<EOL><INDENT>align_copy = False<EOL>if kwargs.get('<STR_LIT>', True):<EOL><INDENT>align_keys = ['<STR_LIT>', '<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>align_keys = ['<STR_LIT>']<EOL><DEDENT><DEDENT>elif f == '<STR_LIT>':<EOL><INDENT>align_copy = False<EOL>align_keys = ['<STR_LIT:value>']<EOL><DEDENT>else:<EOL><INDENT>align_keys = []<EOL><DEDENT>aligned_args = {k: kwargs[k]<EOL>for k in align_keys<EOL>if hasattr(kwargs[k], '<STR_LIT>') and<EOL>not isinstance(kwargs[k], ABCExtensionArray)}<EOL>for b in self.blocks:<EOL><INDENT>if filter is not None:<EOL><INDENT>if not b.mgr_locs.isin(filter_locs).any():<EOL><INDENT>result_blocks.append(b)<EOL>continue<EOL><DEDENT><DEDENT>if aligned_args:<EOL><INDENT>b_items = self.items[b.mgr_locs.indexer]<EOL>for k, obj in aligned_args.items():<EOL><INDENT>axis = getattr(obj, '<STR_LIT>', <NUM_LIT:0>)<EOL>kwargs[k] = obj.reindex(b_items, axis=axis,<EOL>copy=align_copy)<EOL><DEDENT><DEDENT>applied = getattr(b, f)(**kwargs)<EOL>result_blocks = _extend_blocks(applied, result_blocks)<EOL><DEDENT>if len(result_blocks) == <NUM_LIT:0>:<EOL><INDENT>return self.make_empty(axes or self.axes)<EOL><DEDENT>bm = self.__class__(result_blocks, axes or self.axes,<EOL>do_integrity_check=do_integrity_check)<EOL>bm._consolidate_inplace()<EOL>return bm<EOL>
iterate over the blocks, collect and create a new block manager

Parameters
----------
f : the callable or function name to operate on at the block level
axes : optional (if not supplied, use self.axes)
filter : list, if supplied, only call the block if the filter is in
         the block
do_integrity_check : boolean, default False. Do the block manager
    integrity check
consolidate: boolean, default True. Join together blocks having same
    dtype

Returns
-------
Block Manager (new object)