def cross_fields(
    data: pd.DataFrame,
    y: str,
    xs: [str],
    bins: int
) -> pd.DataFrame:
    """

    :param data:
    :param y:
    :param xs:
    :param bins:
    :return:
    """
    if not (xs and y):
        return data

    d = data[list(xs)+[y]].copy()
    for x in list(xs)+[y]:
        try:
            # if the data is not a number type() will raise an exception
            if isinstance(data[x].dtype.type(), np.number):
                d[x], _ = pd.cut(data[x].copy(), bins=bins, retbins=True)
        except:
            pass

    return pd.crosstab([d[f] for f in xs], d[y])
def cross_fields ( data : pd . DataFrame , y : str , xs : [ str ] , bins : int ) -> pd . DataFrame : if not ( xs and y ) : return data d = data [ list ( xs ) + [ y ] ] . copy ( ) for x in list ( xs ) + [ y ] : try : if isinstance ( data [ x ] . dtype . type ( ) , np . number ) : d [ x ] , _ = pd . cut ( data [ x ] . copy ( ) , bins = bins , retbins = True ) except : pass return pd . crosstab ( [ d [ f ] for f in xs ] , d [ y ] )
:param data:
    :param y:
    :param xs:
    :param bins:
    :return: