MAINT: Remove non-standard and inconsistently-used imports
of nan and ndarray.

Wrap some docstring lines.

Split off from #17083 

 - [ ] closes #xxxx
 - [ ] tests added / passed
 - [ ] passes ``git diff upstream/master -u -- "*.py" | flake8 --diff``
 - [ ] whatsnew entry
