Maybe move this convenience function somewhere else if it can't be replaced with pandas functionality (see above). Perhaps utils/data.py?