ENH: added proper handling of nans for numpy.lib.function_base.median. This
closes ticket# 2126 (issue #586)