def METHOD_NAME(matrix, row_idx=None, col_idx=None, num_bins=None):
    """
    Given a 2D DataFrame, ndarray or sparse equivalent, create and return a Matrix flatbuffer.
    :param matrix: 2D DataFrame, ndarray or sparse equivalent
    :param row_idx: array-like index for row dimension or pandas.Index (not supported)
    :param col_idx: array-like index for col dimension or pandas.Index
    :param num_bins: number of bins to use for lossy compression of float data. if unset, no compression.
    NOTE: row indices are (currently) unsupported and must be None
    """
    if row_idx is not None:
        raise ValueError("row indexing not supported for FBS Matrix")
    if matrix.ndim != 2:
        raise ValueError("FBS Matrix must be 2D")
    if sparse.issparse(matrix):
        matrix = matrix.A
    (n_rows, n_cols) = matrix.shape
    # estimate size needed, so we don't unnecessarily realloc.
    builder = Builder(guess_at_mem_needed(matrix))
    columns = []
    for cidx in range(n_cols - 1, -1, -1):
        # serialize the typed array
        col = matrix.iloc[:, cidx] if isinstance(matrix, pd.DataFrame) else matrix[:, cidx]
        typed_arr = serialize_typed_array(builder, col, num_bins=num_bins)
        # serialize the Column union
        columns.append(serialize_column(builder, typed_arr))
    # Serialize Matrix.columns[]
    Matrix.MatrixStartColumnsVector(builder, n_cols)
    for c in columns:
        builder.PrependUOffsetTRelative(c)
    matrix_column_vec = builder.EndVector(n_cols)
    # serialize the colIndex if provided
    cidx = None
    if col_idx is not None:
        cidx = serialize_typed_array(builder, col_idx)
    # Serialize Matrix
    matrix = serialize_matrix(builder, n_rows, n_cols, matrix_column_vec, cidx)
    builder.Finish(matrix)
    return builder.Output()