CLN: clean up data.py

closes #4001, #3982 .