def _is_int(x, tp):
    """Determine whether a column can be cast to int
    without loss of data
    """
    if not any([tp.startswith(i) for i in ('float', 'int')]):
        return False

    # if there's no difference between the two, then it's an int.
    try:
        return (x - x.astype('int')).abs().sum() == 0
    except ValueError:  # happens when there are NaNs
        return False