add pandas_dtype util functions
clean up ugly functional code