(tab, include_metas=False)
return unsorted_columns_df[original_column_order]
Convert Orange.data.Table to pandas.DataFrame

    Parameters
    ----------
    tab : Table

    include_metas : bool, (default=False)
        Include table metas into dataframe.

    Returns
    -------
    pandas.DataFrame
Convert Orange.data.Table to pandas.DataFrame
Convert Orange . data . Table to pandas . DataFrame
def table_to_frame(tab, include_metas=False):
    """
    Convert Orange.data.Table to pandas.DataFrame

    Parameters
    ----------
    tab : Table

    include_metas : bool, (default=False)
        Include table metas into dataframe.

    Returns
    -------
    pandas.DataFrame
    """

    def _column_to_series(col, vals):
        result = ()
        if col.is_discrete:
            codes = pd.Series(vals).fillna(-1).astype(int)
            result = (col.name, pd.Categorical.from_codes(
                codes=codes, categories=col.values, ordered=True
            ))
        elif col.is_time:
            result = (col.name, pd.to_datetime(vals, unit='s').to_series().reset_index()[0])
        elif col.is_continuous:
            dt = float
            # np.nan are not compatible with int column
            # using pd.isnull since np.isnan fails on array with dtype object
            # which can happen when metas contain column with strings
            if col.number_of_decimals == 0 and not np.any(pd.isnull(vals)):
                dt = int
            result = (col.name, pd.Series(vals).astype(dt))
        elif col.is_string:
            result = (col.name, pd.Series(vals))
        return result

    def _columns_to_series(cols, vals):
        return [_column_to_series(col, vals[:, i]) for i, col in enumerate(cols)]

    x, y, metas = [], [], []
    domain = tab.domain
    if domain.attributes:
        x = _columns_to_series(domain.attributes, tab.X)
    if domain.class_vars:
        y_values = tab.Y.reshape(tab.Y.shape[0], len(domain.class_vars))
        y = _columns_to_series(domain.class_vars, y_values)
    if domain.metas:
        metas = _columns_to_series(domain.metas, tab.metas)
    all_series = dict(x + y + metas)
    all_vars = tab.domain.variables
    if include_metas:
        all_vars += tab.domain.metas
    original_column_order = [var.name for var in all_vars]
    unsorted_columns_df = pd.DataFrame(all_series)
    return unsorted_columns_df[original_column_order]
def table_to_frame ( tab , include_metas = False ) : def _column_to_series ( col , vals ) : result = ( ) if col . is_discrete : codes = pd . Series ( vals ) . fillna ( - 1 ) . astype ( int ) result = ( col . name , pd . Categorical . from_codes ( codes = codes , categories = col . values , ordered = True ) ) elif col . is_time : result = ( col . name , pd . to_datetime ( vals , unit = 's' ) . to_series ( ) . reset_index ( ) [ 0 ] ) elif col . is_continuous : dt = float # np.nan are not compatible with int column # using pd.isnull since np.isnan fails on array with dtype object # which can happen when metas contain column with strings if col . number_of_decimals == 0 and not np . any ( pd . isnull ( vals ) ) : dt = int result = ( col . name , pd . Series ( vals ) . astype ( dt ) ) elif col . is_string : result = ( col . name , pd . Series ( vals ) ) return result def _columns_to_series ( cols , vals ) : return [ _column_to_series ( col , vals [ : , i ] ) for i , col in enumerate ( cols ) ] x , y , metas = [ ] , [ ] , [ ] domain = tab . domain if domain . attributes : x = _columns_to_series ( domain . attributes , tab . X ) if domain . class_vars : y_values = tab . Y . reshape ( tab . Y . shape [ 0 ] , len ( domain . class_vars ) ) y = _columns_to_series ( domain . class_vars , y_values ) if domain . metas : metas = _columns_to_series ( domain . metas , tab . metas ) all_series = dict ( x + y + metas ) all_vars = tab . domain . variables if include_metas : all_vars += tab . domain . metas original_column_order = [ var . name for var in all_vars ] unsorted_columns_df = pd . DataFrame ( all_series ) return unsorted_columns_df [ original_column_order ]