(self, *args, **kwargs)
A pandas DataFrame wrapper for one of Table's numpy arrays:
            - sets index values corresponding to Orange's global row indices
              e.g. ['_o1', '_o2'] (allows Orange to handle selection)
            - remembers the array's role in the Table (attribute, class var, meta)
            - keeps the Variable objects, and uses them in back-to-table conversion,
              should a column name match a variable's name
            - stores weight values (legacy)

        Parameters
        ----------
        table : Table
        orange_role : Role, (default=Role.Attribute)
            When converting back to an orange table, the DataFrame will
            convert to the right role (attrs, class vars, or metas)
A pandas DataFrame wrapper for one of Table's numpy arrays:
            - sets index values corresponding to Orange's global row indices
              e.g. ['_o1', '_o2'] (allows Orange to handle selection)
            - remembers the array's role in the Table (attribute, class var, meta)
            - keeps the Variable objects, and uses them in back-to-table conversion,
              should a column name match a variable's name
            - stores weight values (legacy)
A pandas DataFrame wrapper for one of Table s numpy arrays : - sets index values corresponding to Orange s global row indices e . g . [ _o1 _o2 ] ( allows Orange to handle selection ) - remembers the array s role in the Table ( attribute class var meta ) - keeps the Variable objects and uses them in back - to - table conversion should a column name match a variable s name - stores weight values ( legacy )
def __init__(self, *args, **kwargs):
        """
        A pandas DataFrame wrapper for one of Table's numpy arrays:
            - sets index values corresponding to Orange's global row indices
              e.g. ['_o1', '_o2'] (allows Orange to handle selection)
            - remembers the array's role in the Table (attribute, class var, meta)
            - keeps the Variable objects, and uses them in back-to-table conversion,
              should a column name match a variable's name
            - stores weight values (legacy)

        Parameters
        ----------
        table : Table
        orange_role : Role, (default=Role.Attribute)
            When converting back to an orange table, the DataFrame will
            convert to the right role (attrs, class vars, or metas)
        """
        if len(args) <= 0 or not isinstance(args[0], Table):
            super().__init__(*args, **kwargs)
            return
        table = args[0]
        if 'orange_role' in kwargs:
            role = kwargs.pop('orange_role')
        elif len(args) >= 2:
            role = args[1]
        else:
            role = Role.Attribute

        if role == Role.Attribute:
            data = table.X
            vars_ = table.domain.attributes
        elif role == Role.ClassAttribute:
            data = table.Y
            vars_ = table.domain.class_vars
        else:  # if role == Role.Meta:
            data = table.metas
            vars_ = table.domain.metas

        index = ['_o' + str(id_) for id_ in table.ids]
        varsdict = {var._name: var for var in vars_}
        columns = varsdict.keys()

        if sp.issparse(data):
            data = data.asformat('csc')
            sparrays = [SparseArray.from_spmatrix(data[:, i]) for i in range(data.shape[1])]
            data = dict(enumerate(sparrays))
            super().__init__(data, index=index, **kwargs)
            self.columns = columns
            # a hack to keep Orange df _metadata in sparse->dense conversion
            self.sparse.to_dense = self.__patch_constructor(self.sparse.to_dense)
        else:
            super().__init__(data=data, index=index, columns=columns, **kwargs)

        self.orange_role = role
        self.orange_variables = varsdict
        self.orange_weights = (dict(zip(index, table.W))
                               if table.W.size > 0 else {})
        self.orange_attributes = table.attributes
def __init__ ( self , * args , * * kwargs ) : if len ( args ) <= 0 or not isinstance ( args [ 0 ] , Table ) : super ( ) . __init__ ( * args , * * kwargs ) return table = args [ 0 ] if 'orange_role' in kwargs : role = kwargs . pop ( 'orange_role' ) elif len ( args ) >= 2 : role = args [ 1 ] else : role = Role . Attribute if role == Role . Attribute : data = table . X vars_ = table . domain . attributes elif role == Role . ClassAttribute : data = table . Y vars_ = table . domain . class_vars else : # if role == Role.Meta: data = table . metas vars_ = table . domain . metas index = [ '_o' + str ( id_ ) for id_ in table . ids ] varsdict = { var . _name : var for var in vars_ } columns = varsdict . keys ( ) if sp . issparse ( data ) : data = data . asformat ( 'csc' ) sparrays = [ SparseArray . from_spmatrix ( data [ : , i ] ) for i in range ( data . shape [ 1 ] ) ] data = dict ( enumerate ( sparrays ) ) super ( ) . __init__ ( data , index = index , * * kwargs ) self . columns = columns # a hack to keep Orange df _metadata in sparse->dense conversion self . sparse . to_dense = self . __patch_constructor ( self . sparse . to_dense ) else : super ( ) . __init__ ( data = data , index = index , columns = columns , * * kwargs ) self . orange_role = role self . orange_variables = varsdict self . orange_weights = ( dict ( zip ( index , table . W ) ) if table . W . size > 0 else { } ) self . orange_attributes = table . attributes