def coerce_numeric(arr):
    # already numeric type
    if np.issubdtype(arr.dtype, np.number):
        return arr

    if np.issubdtype(arr.dtype, np.bool_):
        return arr.astype(np.int)

    # a string dtype, or anything else
    try:
        return pd.to_numeric(arr, errors='coerce')
    except AttributeError:  # older versions of pandas
        return pd.Series(arr).convert_objects(convert_numeric=True).values
Coerce an array into a numeric array, replacing non-numeric elements with
dataset/ETHPy150Open glue-viz/glue/glue/utils/array.py/coerce_numeric