{
    "file_diffs": [
        {
            "old_file_content": "\"\"\"Pandas DataFrame↔Table conversion helpers\"\"\"\nfrom unittest.mock import patch\n\nimport numpy as np\nfrom pandas.core.dtypes.common import is_string_dtype\nfrom scipy import sparse as sp\nfrom scipy.sparse import csr_matrix\nimport pandas as pd\nfrom pandas.core.arrays import SparseArray\nfrom pandas.core.arrays.sparse.dtype import SparseDtype\nfrom pandas.api.types import (\n    is_categorical_dtype, is_object_dtype,\n    is_datetime64_any_dtype, is_numeric_dtype, is_integer_dtype\n)\n\nfrom Orange.data import (\n    Table, Domain, DiscreteVariable, StringVariable, TimeVariable,\n    ContinuousVariable,\n)\nfrom Orange.data.table import Role\n\n__all__ = ['table_from_frame', 'table_to_frame']\n\n\nclass OrangeDataFrame(pd.DataFrame):\n    _metadata = [\"orange_variables\", \"orange_weights\",\n                 \"orange_attributes\", \"orange_role\"]\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n        A pandas DataFrame wrapper for one of Table's numpy arrays:\n            - sets index values corresponding to Orange's global row indices\n              e.g. ['_o1', '_o2'] (allows Orange to handle selection)\n            - remembers the array's role in the Table (attribute, class var, meta)\n            - keeps the Variable objects, and uses them in back-to-table conversion,\n              should a column name match a variable's name\n            - stores weight values (legacy)\n\n        Parameters\n        ----------\n        table : Table\n        orange_role : Role, (default=Role.Attribute)\n            When converting back to an orange table, the DataFrame will\n            convert to the right role (attrs, class vars, or metas)\n        \"\"\"\n        if len(args) <= 0 or not isinstance(args[0], Table):\n            super().__init__(*args, **kwargs)\n            return\n        table = args[0]\n        if 'orange_role' in kwargs:\n            role = kwargs.pop('orange_role')\n        elif len(args) >= 2:\n            role = args[1]\n        else:\n            role = Role.Attribute\n\n        if role == Role.Attribute:\n            data = table.X\n            vars_ = table.domain.attributes\n        elif role == Role.ClassAttribute:\n            data = table.Y\n            vars_ = table.domain.class_vars\n        else:  # if role == Role.Meta:\n            data = table.metas\n            vars_ = table.domain.metas\n\n        index = ['_o' + str(id_) for id_ in table.ids]\n        varsdict = {var._name: var for var in vars_}\n        columns = varsdict.keys()\n\n        if sp.issparse(data):\n            data = data.asformat('csc')\n            sparrays = [SparseArray.from_spmatrix(data[:, i]) for i in range(data.shape[1])]\n            data = dict(enumerate(sparrays))\n            super().__init__(data, index=index, **kwargs)\n            self.columns = columns\n            # a hack to keep Orange df _metadata in sparse->dense conversion\n            self.sparse.to_dense = self.__patch_constructor(self.sparse.to_dense)\n        else:\n            super().__init__(data=data, index=index, columns=columns, **kwargs)\n\n        self.orange_role = role\n        self.orange_variables = varsdict\n        self.orange_weights = (dict(zip(index, table.W))\n                               if table.W.size > 0 else {})\n        self.orange_attributes = table.attributes\n\n    def __patch_constructor(self, method):\n        def new_method(*args, **kwargs):\n            with patch(\n                    'pandas.DataFrame',\n                    OrangeDataFrame\n            ):\n                df = method(*args, **kwargs)\n            df.__finalize__(self)\n            return df\n\n        return new_method\n\n    @property\n    def _constructor(self):\n        return OrangeDataFrame\n\n    def to_orange_table(self):\n        return table_from_frame(self)\n\n    def __finalize__(self, other, method=None, **_):\n        \"\"\"\n        propagate metadata from other to self\n\n        Parameters\n        ----------\n        other : the object from which to get the attributes that we are going\n            to propagate\n        method : optional, a passed method name ; possibly to take different\n            types of propagation actions based on this\n\n        \"\"\"\n        if method == 'concat':\n            objs = other.objs\n        elif method == 'merge':\n            objs = other.left, other.right\n        else:\n            objs = [other]\n\n        orange_role = getattr(self, 'orange_role', None)\n        dicts = {dname: getattr(self, dname, {})\n                 for dname in ('orange_variables',\n                               'orange_weights',\n                               'orange_attributes')}\n        for obj in objs:\n            other_role = getattr(obj, 'orange_role', None)\n            if other_role is not None:\n                orange_role = other_role\n\n            for dname, dict_ in dicts.items():\n                other_dict = getattr(obj, dname, {})\n                dict_.update(other_dict)\n\n        object.__setattr__(self, 'orange_role', orange_role)\n        for dname, dict_ in dicts.items():\n            object.__setattr__(self, dname, dict_)\n\n        return self\n\n    pd.DataFrame.__finalize__ = __finalize__\n\n\ndef _reset_index(df: pd.DataFrame) -> pd.DataFrame:\n    \"\"\"If df index is not a simple RangeIndex (or similar), include it into a table\"\"\"\n    if (\n        # not range-like index - test first to skip slow startswith(_o) check\n        not (\n            df.index.is_integer()\n            and (df.index.is_monotonic_increasing or df.index.is_monotonic_decreasing)\n        )\n        # check that it does not contain Orange index\n        and (\n            # startswith is slow (for long dfs) - firs check if col has strings\n            isinstance(df.index, pd.MultiIndex)\n            or not is_string_dtype(df.index)\n            or not any(str(i).startswith(\"_o\") for i in df.index)\n        )\n    ):\n        df = df.reset_index()\n    return df\n\n\ndef _is_discrete(s, force_nominal):\n    return (is_categorical_dtype(s) or\n            is_object_dtype(s) and (force_nominal or\n                                    s.nunique() < s.size ** .666))\n\n\ndef _is_datetime(s):\n    if is_datetime64_any_dtype(s):\n        return True\n    try:\n        if is_object_dtype(s):\n            # pd.to_datetime would sucessfuly parse column of numbers to datetime\n            # but for column of object dtype with numbers we want to be either\n            # discret or string - following code try to parse column to numeric\n            # if connversion to numeric is sucessful return False\n            try:\n                pd.to_numeric(s)\n                return False\n            except (ValueError, TypeError):\n                pass\n\n            # utc=True - to allow different timezones in a series object\n            pd.to_datetime(s, infer_datetime_format=True, utc=True)\n            return True\n    except Exception:  # pylint: disable=broad-except\n        pass\n    return False\n\n\ndef _convert_datetime(series, var):\n    def col_type(dt):\n        \"\"\"Test if is date, time or datetime\"\"\"\n        dt_nonnat = dt[~pd.isnull(dt)]  # nat == nat is False\n        if (dt_nonnat.dt.floor(\"d\") == dt_nonnat).all():\n            # all times are 00:00:00.0 - pure date\n            return 1, 0\n        elif (dt_nonnat.dt.date == pd.Timestamp(\"now\").date()).all():\n            # all dates are today's date - pure time\n            return 0, 1  # pure time\n        else:\n            # else datetime\n            return 1, 1\n\n    try:\n        dt = pd.to_datetime(series)\n    except ValueError:\n        # series with type object and different timezones will raise a\n        # ValueError - normalizing to utc\n        dt = pd.to_datetime(series, utc=True)\n\n    # set variable type to date, time or datetime\n    var.have_date, var.have_time = col_type(dt)\n\n    if dt.dt.tz is not None:\n        # set timezone if available and convert to utc\n        var.timezone = dt.dt.tz\n        dt = dt.dt.tz_convert(\"UTC\")\n\n    if var.have_time and not var.have_date:\n        # if time only measure seconds from midnight - equal to setting date\n        # to unix epoch\n        return (\n            (dt.dt.tz_localize(None) - pd.Timestamp(\"now\").normalize())\n            / pd.Timedelta(\"1s\")\n        ).values\n\n    return (\n        (dt.dt.tz_localize(None) - pd.Timestamp(\"1970-01-01\")) / pd.Timedelta(\"1s\")\n    ).values\n\n\ndef to_categorical(s, _):\n    x = s.astype(\"category\").cat.codes\n    # it is same than x.replace(-1, np.nan), but much faster\n    x = x.where(x != -1, np.nan)\n    return np.asarray(x)\n\n\ndef vars_from_df(df, role=None, force_nominal=False):\n    if role is None and hasattr(df, 'orange_role'):\n        role = df.orange_role\n    df = _reset_index(df)\n\n    cols = [], [], []\n    exprs = [], [], []\n    vars_ = [], [], []\n\n    for column in df.columns:\n        s = df[column]\n        _role = Role.Attribute if role is None else role\n        if hasattr(df, 'orange_variables') and column in df.orange_variables:\n            original_var = df.orange_variables[column]\n            var = original_var.copy(compute_value=None)\n            expr = None\n        elif _is_datetime(s):\n            var = TimeVariable(str(column))\n            expr = _convert_datetime\n        elif _is_discrete(s, force_nominal):\n            discrete = s.astype(\"category\").cat\n            var = DiscreteVariable(\n                str(column), discrete.categories.astype(str).tolist()\n            )\n            expr = to_categorical\n        elif is_numeric_dtype(s):\n            var = ContinuousVariable(\n                # set number of decimals to 0 if int else keeps default behaviour\n                str(column), number_of_decimals=(0 if is_integer_dtype(s) else None)\n            )\n            expr = None\n        else:\n            if role is not None and role != Role.Meta:\n                raise ValueError(\"String variable must be in metas.\")\n            _role = Role.Meta\n            var = StringVariable(str(column))\n            expr = lambda s, _: np.asarray(s, dtype=object)\n\n        cols[_role].append(column)\n        exprs[_role].append(expr)\n        vars_[_role].append(var)\n\n    xym = []\n    for a_vars, a_cols, a_expr in zip(vars_, cols, exprs):\n        if not a_cols:\n            arr = None if a_cols != cols[0] else np.empty((df.shape[0], 0))\n        elif not any(a_expr):\n            # if all c in columns table will share memory with dataframe\n            a_df = df if all(c in a_cols for c in df.columns) else df[a_cols]\n            if all(isinstance(a, SparseDtype) for a in a_df.dtypes):\n                arr = csr_matrix(a_df.sparse.to_coo())\n            else:\n                arr = np.asarray(a_df)\n        else:\n            # we'll have to copy the table to resolve any expressions\n            arr = np.array(\n                [\n                    expr(df[col], var) if expr else np.asarray(df[col])\n                    for var, col, expr in zip(a_vars, a_cols, a_expr)\n                ]\n            ).T\n        xym.append(arr)\n\n    # Let the tables share memory with pandas frame\n    if xym[1] is not None and xym[1].ndim == 2 and xym[1].shape[1] == 1:\n        xym[1] = xym[1][:, 0]\n\n    return xym, Domain(*vars_)\n\n\ndef table_from_frame(df, *, force_nominal=False):\n    XYM, domain = vars_from_df(df, force_nominal=force_nominal)\n\n    if hasattr(df, 'orange_weights') and hasattr(df, 'orange_attributes'):\n        W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]\n        if len(W) != len(df.index):\n            W = None\n        attributes = df.orange_attributes\n        if isinstance(df.index, pd.MultiIndex) or not is_string_dtype(df.index):\n            # we can skip checking for Orange indices when MultiIndex an when\n            # not string dtype and so speedup the conversion\n            ids = None\n        else:\n            ids = [\n                int(i[2:])\n                if str(i).startswith(\"_o\") and i[2:].isdigit()\n                else Table.new_id()\n                for i in df.index\n            ]\n    else:\n        W = None\n        attributes = None\n        ids = None\n\n    return Table.from_numpy(\n        domain,\n        *XYM,\n        W=W,\n        attributes=attributes,\n        ids=ids\n    )\n\n\ndef table_from_frames(xdf, ydf, mdf):\n    if not (xdf.index.equals(ydf.index) and xdf.index.equals(mdf.index)):\n        raise ValueError(\n            \"Indexes not equal. Make sure that all three dataframes have equal index\"\n        )\n\n    # drop index from x and y - it makes sure that index if not range will be\n    # placed in metas\n    xdf = xdf.reset_index(drop=True)\n    ydf = ydf.reset_index(drop=True)\n    dfs = xdf, ydf, mdf\n\n    if not all(df.shape[0] == xdf.shape[0] for df in dfs):\n        raise ValueError(f\"Leading dimension mismatch \"\n                         f\"(not {xdf.shape[0]} == {ydf.shape[0]} == {mdf.shape[0]})\")\n\n    xXYM, xDomain = vars_from_df(xdf, role=Role.Attribute)\n    yXYM, yDomain = vars_from_df(ydf, role=Role.ClassAttribute)\n    mXYM, mDomain = vars_from_df(mdf, role=Role.Meta)\n\n    XYM = (xXYM[0], yXYM[1], mXYM[2])\n    domain = Domain(xDomain.attributes, yDomain.class_vars, mDomain.metas)\n\n    ids = [\n        int(idx[2:])\n        if str(idx).startswith(\"_o\") and idx[2:].isdigit()\n        else Table.new_id()\n        for idx in mdf.index\n    ]\n\n    attributes = {}\n    W = None\n    for df in dfs:\n        if isinstance(df, OrangeDataFrame):\n            W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]\n            if len(W) != len(df.index):\n                W = None\n            attributes.update(df.orange_attributes)\n        else:\n            W = None\n\n    return Table.from_numpy(\n        domain,\n        *XYM,\n        W=W,\n        attributes=attributes,\n        ids=ids\n    )\n\n\ndef table_to_frame(tab, include_metas=False):\n    \"\"\"\n    Convert Orange.data.Table to pandas.DataFrame\n\n    Parameters\n    ----------\n    tab : Table\n\n    include_metas : bool, (default=False)\n        Include table metas into dataframe.\n\n    Returns\n    -------\n    pandas.DataFrame\n    \"\"\"\n\n    def _column_to_series(col, vals):\n        result = ()\n        if col.is_discrete:\n            codes = pd.Series(vals).fillna(-1).astype(int)\n            result = (col.name, pd.Categorical.from_codes(\n                codes=codes, categories=col.values, ordered=True\n            ))\n        elif col.is_time:\n            result = (col.name, pd.to_datetime(vals, unit='s').to_series().reset_index()[0])\n        elif col.is_continuous:\n            dt = float\n            # np.nan are not compatible with int column\n            # using pd.isnull since np.isnan fails on array with dtype object\n            # which can happen when metas contain column with strings\n            if col.number_of_decimals == 0 and not np.any(pd.isnull(vals)):\n                dt = int\n            result = (col.name, pd.Series(vals).astype(dt))\n        elif col.is_string:\n            result = (col.name, pd.Series(vals))\n        return result\n\n    def _columns_to_series(cols, vals):\n        return [_column_to_series(col, vals[:, i]) for i, col in enumerate(cols)]\n\n    x, y, metas = [], [], []\n    domain = tab.domain\n    if domain.attributes:\n        x = _columns_to_series(domain.attributes, tab.X)\n    if domain.class_vars:\n        y_values = tab.Y.reshape(tab.Y.shape[0], len(domain.class_vars))\n        y = _columns_to_series(domain.class_vars, y_values)\n    if domain.metas:\n        metas = _columns_to_series(domain.metas, tab.metas)\n    all_series = dict(x + y + metas)\n    all_vars = tab.domain.variables\n    if include_metas:\n        all_vars += tab.domain.metas\n    original_column_order = [var.name for var in all_vars]\n    unsorted_columns_df = pd.DataFrame(all_series)\n    return unsorted_columns_df[original_column_order]\n\n\ndef table_to_frames(table):\n    xdf = OrangeDataFrame(table, Role.Attribute)\n    ydf = OrangeDataFrame(table, Role.ClassAttribute)\n    mdf = OrangeDataFrame(table, Role.Meta)\n\n    return xdf, ydf, mdf\n\n\ndef amend_table_with_frame(table, df, role):\n    arr = Role.get_arr(role, table)\n    if arr.shape[0] != df.shape[0]:\n        raise ValueError(f\"Leading dimension mismatch \"\n                         f\"(not {arr.shape[0]} == {df.shape[0]})\")\n\n    XYM, domain = vars_from_df(df, role=role)\n\n    if role == Role.Attribute:\n        table.domain = Domain(domain.attributes,\n                              table.domain.class_vars,\n                              table.domain.metas)\n        table.X = XYM[0]\n    elif role == Role.ClassAttribute:\n        table.domain = Domain(table.domain.attributes,\n                              domain.class_vars,\n                              table.domain.metas)\n        table.Y = XYM[1]\n    else:  # if role == Role.Meta:\n        table.domain = Domain(table.domain.attributes,\n                              table.domain.class_vars,\n                              domain.metas)\n        table.metas = XYM[2]\n\n    if isinstance(df, OrangeDataFrame):\n        table.attributes.update(df.orange_attributes)\n",
            "new_file_content": "\"\"\"Pandas DataFrame↔Table conversion helpers\"\"\"\nfrom unittest.mock import patch\n\nimport numpy as np\nfrom pandas.core.dtypes.common import is_string_dtype\nfrom scipy import sparse as sp\nfrom scipy.sparse import csr_matrix\nimport pandas as pd\nfrom pandas.core.arrays import SparseArray\nfrom pandas.core.arrays.sparse.dtype import SparseDtype\nfrom pandas.api.types import (\n    is_categorical_dtype, is_object_dtype,\n    is_datetime64_any_dtype, is_numeric_dtype, is_integer_dtype\n)\n\nfrom Orange.data import (\n    Table, Domain, DiscreteVariable, StringVariable, TimeVariable,\n    ContinuousVariable,\n)\nfrom Orange.data.table import Role\n\n__all__ = ['table_from_frame', 'table_to_frame']\n\n\nclass OrangeDataFrame(pd.DataFrame):\n    _metadata = [\"orange_variables\", \"orange_weights\",\n                 \"orange_attributes\", \"orange_role\"]\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n        A pandas DataFrame wrapper for one of Table's numpy arrays:\n            - sets index values corresponding to Orange's global row indices\n              e.g. ['_o1', '_o2'] (allows Orange to handle selection)\n            - remembers the array's role in the Table (attribute, class var, meta)\n            - keeps the Variable objects, and uses them in back-to-table conversion,\n              should a column name match a variable's name\n            - stores weight values (legacy)\n\n        Parameters\n        ----------\n        table : Table\n        orange_role : Role, (default=Role.Attribute)\n            When converting back to an orange table, the DataFrame will\n            convert to the right role (attrs, class vars, or metas)\n        \"\"\"\n        if len(args) <= 0 or not isinstance(args[0], Table):\n            super().__init__(*args, **kwargs)\n            return\n        table = args[0]\n        if 'orange_role' in kwargs:\n            role = kwargs.pop('orange_role')\n        elif len(args) >= 2:\n            role = args[1]\n        else:\n            role = Role.Attribute\n\n        if role == Role.Attribute:\n            data = table.X\n            vars_ = table.domain.attributes\n        elif role == Role.ClassAttribute:\n            data = table.Y\n            vars_ = table.domain.class_vars\n        else:  # if role == Role.Meta:\n            data = table.metas\n            vars_ = table.domain.metas\n\n        index = ['_o' + str(id_) for id_ in table.ids]\n        varsdict = {var._name: var for var in vars_}\n        columns = varsdict.keys()\n\n        if sp.issparse(data):\n            data = data.asformat('csc')\n            sparrays = [SparseArray.from_spmatrix(data[:, i]) for i in range(data.shape[1])]\n            data = dict(enumerate(sparrays))\n            super().__init__(data, index=index, **kwargs)\n            self.columns = columns\n            # a hack to keep Orange df _metadata in sparse->dense conversion\n            self.sparse.to_dense = self.__patch_constructor(self.sparse.to_dense)\n        else:\n            super().__init__(data=data, index=index, columns=columns, **kwargs)\n\n        self.orange_role = role\n        self.orange_variables = varsdict\n        self.orange_weights = (dict(zip(index, table.W))\n                               if table.W.size > 0 else {})\n        self.orange_attributes = table.attributes\n\n    def __patch_constructor(self, method):\n        def new_method(*args, **kwargs):\n            with patch(\n                    'pandas.DataFrame',\n                    OrangeDataFrame\n            ):\n                df = method(*args, **kwargs)\n            df.__finalize__(self)\n            return df\n\n        return new_method\n\n    @property\n    def _constructor(self):\n        return OrangeDataFrame\n\n    def to_orange_table(self):\n        return table_from_frame(self)\n\n    def __finalize__(self, other, method=None, **_):\n        \"\"\"\n        propagate metadata from other to self\n\n        Parameters\n        ----------\n        other : the object from which to get the attributes that we are going\n            to propagate\n        method : optional, a passed method name ; possibly to take different\n            types of propagation actions based on this\n\n        \"\"\"\n        if method == 'concat':\n            objs = other.objs\n        elif method == 'merge':\n            objs = other.left, other.right\n        else:\n            objs = [other]\n\n        orange_role = getattr(self, 'orange_role', None)\n        dicts = {dname: getattr(self, dname, {})\n                 for dname in ('orange_variables',\n                               'orange_weights',\n                               'orange_attributes')}\n        for obj in objs:\n            other_role = getattr(obj, 'orange_role', None)\n            if other_role is not None:\n                orange_role = other_role\n\n            for dname, dict_ in dicts.items():\n                other_dict = getattr(obj, dname, {})\n                dict_.update(other_dict)\n\n        object.__setattr__(self, 'orange_role', orange_role)\n        for dname, dict_ in dicts.items():\n            object.__setattr__(self, dname, dict_)\n\n        return self\n\n    pd.DataFrame.__finalize__ = __finalize__\n\n\ndef _reset_index(df: pd.DataFrame) -> pd.DataFrame:\n    \"\"\"If df index is not a simple RangeIndex (or similar), include it into a table\"\"\"\n    if (\n        # not range-like index - test first to skip slow startswith(_o) check\n        not (\n            df.index.is_integer()\n            and (df.index.is_monotonic_increasing or df.index.is_monotonic_decreasing)\n        )\n        # check that it does not contain Orange index\n        and (\n            # startswith is slow (for long dfs) - firs check if col has strings\n            isinstance(df.index, pd.MultiIndex)\n            or not is_string_dtype(df.index)\n            or not any(str(i).startswith(\"_o\") for i in df.index)\n        )\n    ):\n        df = df.reset_index()\n    return df\n\n\ndef _is_discrete(s, force_nominal):\n    return (is_categorical_dtype(s) or\n            is_object_dtype(s) and (force_nominal or\n                                    s.nunique() < s.size ** .666))\n\n\ndef _is_datetime(s):\n    if is_datetime64_any_dtype(s):\n        return True\n    try:\n        if is_object_dtype(s):\n            # pd.to_datetime would sucessfuly parse column of numbers to datetime\n            # but for column of object dtype with numbers we want to be either\n            # discret or string - following code try to parse column to numeric\n            # if connversion to numeric is sucessful return False\n            try:\n                pd.to_numeric(s)\n                return False\n            except (ValueError, TypeError):\n                pass\n\n            # utc=True - to allow different timezones in a series object\n            pd.to_datetime(s, infer_datetime_format=True, utc=True)\n            return True\n    except Exception:  # pylint: disable=broad-except\n        pass\n    return False\n\n\ndef _convert_datetime(series, var):\n    def col_type(dt):\n        \"\"\"Test if is date, time or datetime\"\"\"\n        dt_nonnat = dt[~pd.isnull(dt)]  # nat == nat is False\n        if (dt_nonnat.dt.floor(\"d\") == dt_nonnat).all():\n            # all times are 00:00:00.0 - pure date\n            return 1, 0\n        elif (dt_nonnat.dt.date == pd.Timestamp(\"now\").date()).all():\n            # all dates are today's date - pure time\n            return 0, 1  # pure time\n        else:\n            # else datetime\n            return 1, 1\n\n    try:\n        dt = pd.to_datetime(series)\n    except ValueError:\n        # series with type object and different timezones will raise a\n        # ValueError - normalizing to utc\n        dt = pd.to_datetime(series, utc=True)\n\n    # set variable type to date, time or datetime\n    var.have_date, var.have_time = col_type(dt)\n\n    if dt.dt.tz is not None:\n        # set timezone if available and convert to utc\n        var.timezone = dt.dt.tz\n        dt = dt.dt.tz_convert(\"UTC\")\n\n    if var.have_time and not var.have_date:\n        # if time only measure seconds from midnight - equal to setting date\n        # to unix epoch\n        return (\n            (dt.dt.tz_localize(None) - pd.Timestamp(\"now\").normalize())\n            / pd.Timedelta(\"1s\")\n        ).values\n\n    return (\n        (dt.dt.tz_localize(None) - pd.Timestamp(\"1970-01-01\")) / pd.Timedelta(\"1s\")\n    ).values\n\n\ndef to_categorical(s, _):\n    x = s.astype(\"category\").cat.codes\n    # it is same than x.replace(-1, np.nan), but much faster\n    x = x.where(x != -1, np.nan)\n    return np.asarray(x)\n\n\ndef vars_from_df(df, role=None, force_nominal=False):\n    if role is None and hasattr(df, 'orange_role'):\n        role = df.orange_role\n    df = _reset_index(df)\n\n    cols = [], [], []\n    exprs = [], [], []\n    vars_ = [], [], []\n\n    for column in df.columns:\n        s = df[column]\n        _role = Role.Attribute if role is None else role\n        if hasattr(df, 'orange_variables') and column in df.orange_variables:\n            original_var = df.orange_variables[column]\n            var = original_var.copy(compute_value=None)\n            expr = None\n        elif _is_datetime(s):\n            var = TimeVariable(str(column))\n            expr = _convert_datetime\n        elif _is_discrete(s, force_nominal):\n            discrete = s.astype(\"category\").cat\n            var = DiscreteVariable(\n                str(column), discrete.categories.astype(str).tolist()\n            )\n            expr = to_categorical\n        elif is_numeric_dtype(s):\n            var = ContinuousVariable(\n                # set number of decimals to 0 if int else keeps default behaviour\n                str(column), number_of_decimals=(0 if is_integer_dtype(s) else None)\n            )\n            expr = None\n        else:\n            if role is not None and role != Role.Meta:\n                raise ValueError(\"String variable must be in metas.\")\n            _role = Role.Meta\n            var = StringVariable(str(column))\n            expr = lambda s, _: np.asarray(\n                # to object so that fillna can replace with nans if Unknown in nan\n                # replace nan with object Unknown assure that all values are string\n                s.astype(object).fillna(StringVariable.Unknown).astype(str),\n                dtype=object\n            )\n\n        cols[_role].append(column)\n        exprs[_role].append(expr)\n        vars_[_role].append(var)\n\n    xym = []\n    for a_vars, a_cols, a_expr in zip(vars_, cols, exprs):\n        if not a_cols:\n            arr = None if a_cols != cols[0] else np.empty((df.shape[0], 0))\n        elif not any(a_expr):\n            # if all c in columns table will share memory with dataframe\n            a_df = df if all(c in a_cols for c in df.columns) else df[a_cols]\n            if all(isinstance(a, SparseDtype) for a in a_df.dtypes):\n                arr = csr_matrix(a_df.sparse.to_coo())\n            else:\n                arr = np.asarray(a_df)\n        else:\n            # we'll have to copy the table to resolve any expressions\n            arr = np.array(\n                [\n                    expr(df[col], var) if expr else np.asarray(df[col])\n                    for var, col, expr in zip(a_vars, a_cols, a_expr)\n                ]\n            ).T\n        xym.append(arr)\n\n    # Let the tables share memory with pandas frame\n    if xym[1] is not None and xym[1].ndim == 2 and xym[1].shape[1] == 1:\n        xym[1] = xym[1][:, 0]\n\n    return xym, Domain(*vars_)\n\n\ndef table_from_frame(df, *, force_nominal=False):\n    XYM, domain = vars_from_df(df, force_nominal=force_nominal)\n\n    if hasattr(df, 'orange_weights') and hasattr(df, 'orange_attributes'):\n        W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]\n        if len(W) != len(df.index):\n            W = None\n        attributes = df.orange_attributes\n        if isinstance(df.index, pd.MultiIndex) or not is_string_dtype(df.index):\n            # we can skip checking for Orange indices when MultiIndex an when\n            # not string dtype and so speedup the conversion\n            ids = None\n        else:\n            ids = [\n                int(i[2:])\n                if str(i).startswith(\"_o\") and i[2:].isdigit()\n                else Table.new_id()\n                for i in df.index\n            ]\n    else:\n        W = None\n        attributes = None\n        ids = None\n\n    return Table.from_numpy(\n        domain,\n        *XYM,\n        W=W,\n        attributes=attributes,\n        ids=ids\n    )\n\n\ndef table_from_frames(xdf, ydf, mdf):\n    if not (xdf.index.equals(ydf.index) and xdf.index.equals(mdf.index)):\n        raise ValueError(\n            \"Indexes not equal. Make sure that all three dataframes have equal index\"\n        )\n\n    # drop index from x and y - it makes sure that index if not range will be\n    # placed in metas\n    xdf = xdf.reset_index(drop=True)\n    ydf = ydf.reset_index(drop=True)\n    dfs = xdf, ydf, mdf\n\n    if not all(df.shape[0] == xdf.shape[0] for df in dfs):\n        raise ValueError(f\"Leading dimension mismatch \"\n                         f\"(not {xdf.shape[0]} == {ydf.shape[0]} == {mdf.shape[0]})\")\n\n    xXYM, xDomain = vars_from_df(xdf, role=Role.Attribute)\n    yXYM, yDomain = vars_from_df(ydf, role=Role.ClassAttribute)\n    mXYM, mDomain = vars_from_df(mdf, role=Role.Meta)\n\n    XYM = (xXYM[0], yXYM[1], mXYM[2])\n    domain = Domain(xDomain.attributes, yDomain.class_vars, mDomain.metas)\n\n    ids = [\n        int(idx[2:])\n        if str(idx).startswith(\"_o\") and idx[2:].isdigit()\n        else Table.new_id()\n        for idx in mdf.index\n    ]\n\n    attributes = {}\n    W = None\n    for df in dfs:\n        if isinstance(df, OrangeDataFrame):\n            W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]\n            if len(W) != len(df.index):\n                W = None\n            attributes.update(df.orange_attributes)\n        else:\n            W = None\n\n    return Table.from_numpy(\n        domain,\n        *XYM,\n        W=W,\n        attributes=attributes,\n        ids=ids\n    )\n\n\ndef table_to_frame(tab, include_metas=False):\n    \"\"\"\n    Convert Orange.data.Table to pandas.DataFrame\n\n    Parameters\n    ----------\n    tab : Table\n\n    include_metas : bool, (default=False)\n        Include table metas into dataframe.\n\n    Returns\n    -------\n    pandas.DataFrame\n    \"\"\"\n\n    def _column_to_series(col, vals):\n        result = ()\n        if col.is_discrete:\n            codes = pd.Series(vals).fillna(-1).astype(int)\n            result = (col.name, pd.Categorical.from_codes(\n                codes=codes, categories=col.values, ordered=True\n            ))\n        elif col.is_time:\n            result = (col.name, pd.to_datetime(vals, unit='s').to_series().reset_index()[0])\n        elif col.is_continuous:\n            dt = float\n            # np.nan are not compatible with int column\n            # using pd.isnull since np.isnan fails on array with dtype object\n            # which can happen when metas contain column with strings\n            if col.number_of_decimals == 0 and not np.any(pd.isnull(vals)):\n                dt = int\n            result = (col.name, pd.Series(vals).astype(dt))\n        elif col.is_string:\n            result = (col.name, pd.Series(vals))\n        return result\n\n    def _columns_to_series(cols, vals):\n        return [_column_to_series(col, vals[:, i]) for i, col in enumerate(cols)]\n\n    x, y, metas = [], [], []\n    domain = tab.domain\n    if domain.attributes:\n        x = _columns_to_series(domain.attributes, tab.X)\n    if domain.class_vars:\n        y_values = tab.Y.reshape(tab.Y.shape[0], len(domain.class_vars))\n        y = _columns_to_series(domain.class_vars, y_values)\n    if domain.metas:\n        metas = _columns_to_series(domain.metas, tab.metas)\n    all_series = dict(x + y + metas)\n    all_vars = tab.domain.variables\n    if include_metas:\n        all_vars += tab.domain.metas\n    original_column_order = [var.name for var in all_vars]\n    unsorted_columns_df = pd.DataFrame(all_series)\n    return unsorted_columns_df[original_column_order]\n\n\ndef table_to_frames(table):\n    xdf = OrangeDataFrame(table, Role.Attribute)\n    ydf = OrangeDataFrame(table, Role.ClassAttribute)\n    mdf = OrangeDataFrame(table, Role.Meta)\n\n    return xdf, ydf, mdf\n\n\ndef amend_table_with_frame(table, df, role):\n    arr = Role.get_arr(role, table)\n    if arr.shape[0] != df.shape[0]:\n        raise ValueError(f\"Leading dimension mismatch \"\n                         f\"(not {arr.shape[0]} == {df.shape[0]})\")\n\n    XYM, domain = vars_from_df(df, role=role)\n\n    if role == Role.Attribute:\n        table.domain = Domain(domain.attributes,\n                              table.domain.class_vars,\n                              table.domain.metas)\n        table.X = XYM[0]\n    elif role == Role.ClassAttribute:\n        table.domain = Domain(table.domain.attributes,\n                              domain.class_vars,\n                              table.domain.metas)\n        table.Y = XYM[1]\n    else:  # if role == Role.Meta:\n        table.domain = Domain(table.domain.attributes,\n                              table.domain.class_vars,\n                              domain.metas)\n        table.metas = XYM[2]\n\n    if isinstance(df, OrangeDataFrame):\n        table.attributes.update(df.orange_attributes)\n",
            "header": {
                "file": {
                    "path": "Orange/data/pandas_compat.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "788c06394",
                "new_commit_hash": "fb80b4954",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/data/pandas_compat.py"
            },
            "plus_file": {
                "path": "b/Orange/data/pandas_compat.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 280,
                            "length": 7
                        },
                        "new_range": {
                            "start": 280,
                            "length": 12
                        },
                        "section": "def vars_from_df(df, role=None, force_nominal=False):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                raise ValueError(\"String variable must be in metas.\")",
                                "type": "context"
                            },
                            {
                                "content": "            _role = Role.Meta",
                                "type": "context"
                            },
                            {
                                "content": "            var = StringVariable(str(column))",
                                "type": "context"
                            },
                            {
                                "content": "            expr = lambda s, _: np.asarray(s, dtype=object)",
                                "type": "deleted"
                            },
                            {
                                "content": "            expr = lambda s, _: np.asarray(",
                                "type": "added"
                            },
                            {
                                "content": "                # to object so that fillna can replace with nans if Unknown in nan",
                                "type": "added"
                            },
                            {
                                "content": "                # replace nan with object Unknown assure that all values are string",
                                "type": "added"
                            },
                            {
                                "content": "                s.astype(object).fillna(StringVariable.Unknown).astype(str),",
                                "type": "added"
                            },
                            {
                                "content": "                dtype=object",
                                "type": "added"
                            },
                            {
                                "content": "            )",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        cols[_role].append(column)",
                                "type": "context"
                            },
                            {
                                "content": "        exprs[_role].append(expr)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/pandas_compat.py",
                            "type": "function",
                            "name": "vars_from_df",
                            "content": "def vars_from_df(df, role=None, force_nominal=False):\n    if role is None and hasattr(df, 'orange_role'):\n        role = df.orange_role\n    df = _reset_index(df)\n\n    cols = [], [], []\n    exprs = [], [], []\n    vars_ = [], [], []\n\n    for column in df.columns:\n        s = df[column]\n        _role = Role.Attribute if role is None else role\n        if hasattr(df, 'orange_variables') and column in df.orange_variables:\n            original_var = df.orange_variables[column]\n            var = original_var.copy(compute_value=None)\n            expr = None\n        elif _is_datetime(s):\n            var = TimeVariable(str(column))\n            expr = _convert_datetime\n        elif _is_discrete(s, force_nominal):\n            discrete = s.astype(\"category\").cat\n            var = DiscreteVariable(\n                str(column), discrete.categories.astype(str).tolist()\n            )\n            expr = to_categorical\n        elif is_numeric_dtype(s):\n            var = ContinuousVariable(\n                # set number of decimals to 0 if int else keeps default behaviour\n                str(column), number_of_decimals=(0 if is_integer_dtype(s) else None)\n            )\n            expr = None\n        else:\n            if role is not None and role != Role.Meta:\n                raise ValueError(\"String variable must be in metas.\")\n            _role = Role.Meta\n            var = StringVariable(str(column))\n            expr = lambda s, _: np.asarray(s, dtype=object)\n\n        cols[_role].append(column)\n        exprs[_role].append(expr)\n        vars_[_role].append(var)\n\n    xym = []\n    for a_vars, a_cols, a_expr in zip(vars_, cols, exprs):\n        if not a_cols:\n            arr = None if a_cols != cols[0] else np.empty((df.shape[0], 0))\n        elif not any(a_expr):\n            # if all c in columns table will share memory with dataframe\n            a_df = df if all(c in a_cols for c in df.columns) else df[a_cols]\n            if all(isinstance(a, SparseDtype) for a in a_df.dtypes):\n                arr = csr_matrix(a_df.sparse.to_coo())\n            else:\n                arr = np.asarray(a_df)\n        else:\n            # we'll have to copy the table to resolve any expressions\n            arr = np.array(\n                [\n                    expr(df[col], var) if expr else np.asarray(df[col])\n                    for var, col, expr in zip(a_vars, a_cols, a_expr)\n                ]\n            ).T\n        xym.append(arr)\n\n    # Let the tables share memory with pandas frame\n    if xym[1] is not None and xym[1].ndim == 2 and xym[1].shape[1] == 1:\n        xym[1] = xym[1][:, 0]\n\n    return xym, Domain(*vars_)",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 247,
                            "end_lineno": 314,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# pylint: disable=import-outside-toplevel\nimport unittest\nfrom datetime import date, datetime, timezone\n\nimport numpy as np\nimport pytz\nfrom scipy.sparse import csr_matrix\nimport scipy.sparse as sp\n\nfrom Orange.data import ContinuousVariable, DiscreteVariable, TimeVariable, Table, Domain, \\\n    StringVariable\nfrom Orange.data.pandas_compat import OrangeDataFrame\nfrom Orange.data.tests.test_variable import TestTimeVariable\n\ntry:\n    import pandas as pd\nexcept ImportError:\n    pd = None\n\n\n@unittest.skipIf(pd is None, \"Missing package 'pandas'\")\nclass TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)\n\n\nclass TestTablePandas(unittest.TestCase):\n    def setUp(self):\n        if not hasattr(self, 'table'):\n            self.skipTest('Base class')\n\n    def test_basic(self):\n        xdf, ydf, mdf = self.table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        self.__arreq__(self.table.X, xtable.X)\n        self.__arreq__(self.table.Y, ytable.Y)\n        self.__arreq__(self.table.metas, mtable.metas)\n        self.__arreq__(self.table.W, xtable.W)\n        self.__arreq__(self.table.W, ytable.W)\n        self.__arreq__(self.table.W, mtable.W)\n        self.assertEqual(self.table.attributes, xtable.attributes)\n        self.assertEqual(self.table.attributes, ytable.attributes)\n        self.assertEqual(self.table.attributes, mtable.attributes)\n        self.__arreq__(self.table.ids, xtable.ids)\n        self.__arreq__(self.table.ids, ytable.ids)\n        self.__arreq__(self.table.ids, mtable.ids)\n\n        d1 = self.table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_slice(self):\n        df = self.table.X_df\n        table2 = df[['c2', 'd1']].to_orange_table()\n\n        self.__arreq__(self.table.ids, table2.ids)\n        self.__arreq__(self.table.W, table2.W)\n        self.__arreq__(self.table.attributes, table2.attributes)\n\n        domain = table2.domain\n        target_domain = Domain([ContinuousVariable(\"c2\"),\n                                DiscreteVariable(\"d1\")])\n\n        self.assertEqual(domain, target_domain)\n\n    def test_copy(self):\n        df = self.table.X_df\n        df2 = df.copy()\n\n        np.testing.assert_array_equal(df.index, df2.index)\n        self.assertEqual(df.orange_variables, df2.orange_variables)\n        self.assertEqual(df.orange_role, df2.orange_role)\n        self.assertEqual(df.orange_attributes, df2.orange_attributes)\n        self.assertEqual(df.orange_weights, df2.orange_weights)\n\n    def test_concat_table(self):\n        domain2 = Domain(\n            [self.table.domain['c2'],\n             self.table.domain['d1']]\n        )\n        table2 = Table.from_numpy(\n            domain2,\n            np.array(\n                [[0, 0],\n                 [1, 1]]),\n            W=np.array([1, 1])\n        )\n\n        df = self.table.X_df\n        df2 = table2.X_df\n        df3 = pd.concat([df, df2])\n        table3 = df3.to_orange_table()\n\n        np.testing.assert_array_equal(table3.ids,\n                                      np.concatenate([self.table.ids,\n                                                      table2.ids]))\n        np.testing.assert_array_equal(table3.W[:-2],\n                                      self.table.W)\n        np.testing.assert_array_equal(table3.W[-2:],\n                                      table2.W)\n\n        attrs = {}\n        attrs.update(self.table.attributes)\n        attrs.update(table2.attributes)\n\n        self.assertEqual(table3.attributes, attrs)\n\n        vars1 = self.table.domain.variables\n        vars2 = table3.domain.variables\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_concat_df(self):\n        df2 = pd.DataFrame(np.array([[0, 0],\n                                     [1, 1]]))\n\n        df = self.table.X_df\n        df3 = pd.concat([df, df2])\n        table3 = df3.to_orange_table()\n\n        np.testing.assert_array_equal(table3.ids[:-2],\n                                      self.table.ids)\n\n        d1 = self.table.domain\n        d2 = table3.domain\n\n        vars1 = d1.attributes\n        vars2 = d2.variables + d2.metas\n\n        for v1 in vars1:\n            self.assertIn(v1, vars2)\n\n    def test_merge(self):\n        domain2 = Domain(\n            [ContinuousVariable(\"c2\"),\n             ContinuousVariable(\"d15\")]\n        )\n        table2 = Table.from_numpy(\n            domain2,\n            np.array(\n                [[0, 4],\n                 [-1, 15],\n                 [1, 23]])\n        )\n\n        df = self.table.X_df\n        df2 = table2.X_df\n        df3 = pd.merge(df, df2, on='c2')\n        table2 = df.to_orange_table()\n        table3 = df3.to_orange_table()\n\n        self.assertEqual(len(table2), len(table3))\n        self.assertEqual(0, table3.W.size)\n        self.assertEqual(self.table.attributes, table3.attributes)\n\n        d1 = table2.domain\n        d2 = table3.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        self.assertEqual(len(vars2), len(vars1) + 1)\n\n        new_var = next(v for v in vars2\n                       if v.name == 'd15')\n        self.assertIsInstance(new_var, ContinuousVariable)\n\n        new_var_excluded = [v for v in vars2\n                            if v != new_var]\n        for v1, v2 in zip(vars1, new_var_excluded):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_new_column(self):\n        df = self.table.X_df\n        table2 = df.to_orange_table()\n        df['new'] = np.array([0, 1, 0, 1, 6, 1, 1])\n        table3 = df.to_orange_table()\n\n        d1 = table2.domain\n        d2 = table3.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        self.assertEqual(len(vars2), len(vars1) + 1)\n\n        new_var = next(v for v in vars2\n                       if v.name == 'new')\n        self.assertIsInstance(new_var, ContinuousVariable)\n\n        new_var_excluded = [v for v in vars2\n                            if v != new_var]\n        for v1, v2 in zip(vars1, new_var_excluded):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_selection(self):\n        df = self.table.X_df\n\n        tsel = self.table[1:3]\n        dfsel = df[1:3].to_orange_table()\n\n        self.__arreq__(tsel.X, dfsel.X)\n        self.__arreq__(tsel.ids, dfsel.ids)\n        self.__arreq__(tsel.W, dfsel.W)\n        self.__arreq__(tsel.attributes, dfsel.attributes)\n\n\nclass TestDenseTablePandas(TestTablePandas):\n    def setUp(self):\n        self.domain = Domain(\n            [ContinuousVariable(\"c1\"),\n             ContinuousVariable(\"c2\"),\n             DiscreteVariable(\"d1\", values=(\"a\", \"b\"))],\n            ContinuousVariable(\"y\"),\n            [ContinuousVariable(\"c3\"),\n             DiscreteVariable(\"d2\", values=(\"c\", \"d\")),\n             StringVariable(\"s1\"),\n             StringVariable(\"s2\")]\n        )\n        metas = np.array(\n            [0, 1, 0, 1, 1, 2, 1] +\n            [0, 0, 0, 0, 4, 1, 1] +\n            \"a  b  c  d  e     f    g\".split() +\n            list(\"ABCDEF\") + [\"\"], dtype=object).reshape(-1, 7).T.copy()\n        self.table = Table.from_numpy(\n            self.domain,\n            np.array(\n                [[0, 0, 0],\n                 [0, -1, 0],\n                 [7, 1, 0],\n                 [1, 1, 1],\n                 [1, 1, 1],\n                 [1, 1, 1],\n                 [1, 1, 1]]),\n            np.array(\n                [0, 1, 0, 1, 1, 1, 1]),\n            metas,\n            attributes={'haha': 'hoho'},\n            W=np.array([0, 1, 1, 0, 1, 0, 1])\n        )\n\n        self.__arreq__ = np.testing.assert_equal\n\n    def test_contiguous_x(self):\n        table = self.table\n        df = table.X_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.X))\n        self.assertTrue(np.shares_memory(df.values, table2.X))\n\n    def test_contiguous_y(self):\n        table = self.table\n        df = table.Y_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.Y))\n        self.assertTrue(np.shares_memory(df.values, table2.Y))\n\n    @unittest.skipUnless(pd.__version__ >= '1.4.0',\n                         'pandas-dev/pandas#39263')\n    def test_contiguous_metas(self):\n        table = self.table\n        df = table.metas_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.metas))\n        self.assertTrue(np.shares_memory(df.values, table2.metas))\n\n    def test_to_dfs(self):\n        table = self.table\n        dfs = table.to_pandas_dfs()\n\n        tables = [df.to_orange_table() for df in dfs]\n        for t in tables:\n            arrs = (t.X, t.Y, t.metas)\n            self.assertEqual(sum(\n                arr.size > 0\n                for arr in arrs\n            ), 1)\n\n    def test_amend(self):\n        with self.table.unlocked():\n            df = self.table.X_df\n            df.iloc[0][0] = 0\n        X = self.table.X\n        with self.table.unlocked():\n            self.table.X_df = df\n        self.assertTrue(np.shares_memory(df.values, X))\n\n    def test_amend_dimension_mismatch(self):\n        df = self.table.X_df\n        df = df.append([0, 1])\n        try:\n            self.table.X_df = df\n        except ValueError as e:\n            self.assertEqual(str(e),\n                             'Leading dimension mismatch (not 7 == 9)')\n        else:\n            self.fail()\n\n\nclass TestSparseTablePandas(TestTablePandas):\n    features = (\n        ContinuousVariable(name=\"c2\"),\n        ContinuousVariable(name=\"Continuous Feature 2\"),\n        DiscreteVariable(name=\"d1\", values=(\"0\", \"1\")),\n        DiscreteVariable(name=\"Discrete Feature 2\",\n                         values=(\"value1\", \"value2\")),\n    )\n\n    class_vars = (\n        ContinuousVariable(name=\"Continuous Class\"),\n        DiscreteVariable(name=\"Discrete Class\", values=(\"m\", \"f\"))\n    )\n\n    feature_data = (\n        (1, 0, 0, 0),\n        (0, 1, 0, 0),\n        (0, 1, 1, 0),\n        (0, 0, 0, 0),\n        (0, 1, 1, 0),\n        (0, 0, 0, 0),\n        (0, 1, 1, 0),\n    )\n\n    class_data = (\n        (1, 0),\n        (0, 1),\n        (1, 0),\n        (0, 1),\n        (1, 0),\n        (0, 1),\n        (1, 0),\n    )\n\n    def setUp(self):\n        self.domain = Domain(attributes=self.features,\n                             class_vars=self.class_vars)\n        table = Table.from_numpy(\n            self.domain,\n            np.array(self.feature_data),\n            np.array(self.class_data),\n        )\n        self.table = Table.from_numpy(\n            self.domain,\n            csr_matrix(table.X),\n            csr_matrix(table.Y),\n            W=np.array([1, 0, 1, 0, 1, 1, 1])\n        )\n\n        def arreq(t1, t2):\n            if all(sp.issparse(t) for t in (t1, t2)):\n                return self.assertEqual((t1 != t2).nnz, 0)\n            else:\n                return np.array_equal(t1, t2)\n\n        self.__arreq__ = arreq\n\n    def test_to_dense(self):\n        df = self.table.X_df\n\n        self.assertIsInstance(df, OrangeDataFrame)\n\n        ddf = df.sparse.to_dense()\n        np.testing.assert_array_equal(df.index, ddf.index)\n        np.testing.assert_array_equal(df.orange_variables, ddf.orange_variables)\n        np.testing.assert_array_equal(df.orange_attributes, ddf.orange_attributes)\n        np.testing.assert_array_equal(df.orange_role, ddf.orange_role)\n        np.testing.assert_array_equal(df.orange_weights, ddf.orange_weights)\n\n        table = self.table.to_dense()\n        table2 = ddf.to_orange_table()\n\n        np.testing.assert_array_equal(table2.X, table.X)\n        np.testing.assert_array_equal(table2.ids, table.ids)\n        np.testing.assert_array_equal(table2.W, table.W)\n        np.testing.assert_array_equal(table2.attributes, table.attributes)\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "new_file_content": "# pylint: disable=import-outside-toplevel\nimport unittest\nfrom datetime import date, datetime, timezone\n\nimport numpy as np\nimport pytz\nfrom scipy.sparse import csr_matrix\nimport scipy.sparse as sp\n\nfrom Orange.data import ContinuousVariable, DiscreteVariable, TimeVariable, Table, Domain, \\\n    StringVariable\nfrom Orange.data.pandas_compat import OrangeDataFrame\nfrom Orange.data.tests.test_variable import TestTimeVariable\n\ntry:\n    import pandas as pd\nexcept ImportError:\n    pd = None\n\n\n@unittest.skipIf(pd is None, \"Missing package 'pandas'\")\nclass TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetime(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n            table.metas,\n        )\n        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)\n\n\nclass TestTablePandas(unittest.TestCase):\n    def setUp(self):\n        if not hasattr(self, 'table'):\n            self.skipTest('Base class')\n\n    def test_basic(self):\n        xdf, ydf, mdf = self.table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        self.__arreq__(self.table.X, xtable.X)\n        self.__arreq__(self.table.Y, ytable.Y)\n        self.__arreq__(self.table.metas, mtable.metas)\n        self.__arreq__(self.table.W, xtable.W)\n        self.__arreq__(self.table.W, ytable.W)\n        self.__arreq__(self.table.W, mtable.W)\n        self.assertEqual(self.table.attributes, xtable.attributes)\n        self.assertEqual(self.table.attributes, ytable.attributes)\n        self.assertEqual(self.table.attributes, mtable.attributes)\n        self.__arreq__(self.table.ids, xtable.ids)\n        self.__arreq__(self.table.ids, ytable.ids)\n        self.__arreq__(self.table.ids, mtable.ids)\n\n        d1 = self.table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_slice(self):\n        df = self.table.X_df\n        table2 = df[['c2', 'd1']].to_orange_table()\n\n        self.__arreq__(self.table.ids, table2.ids)\n        self.__arreq__(self.table.W, table2.W)\n        self.__arreq__(self.table.attributes, table2.attributes)\n\n        domain = table2.domain\n        target_domain = Domain([ContinuousVariable(\"c2\"),\n                                DiscreteVariable(\"d1\")])\n\n        self.assertEqual(domain, target_domain)\n\n    def test_copy(self):\n        df = self.table.X_df\n        df2 = df.copy()\n\n        np.testing.assert_array_equal(df.index, df2.index)\n        self.assertEqual(df.orange_variables, df2.orange_variables)\n        self.assertEqual(df.orange_role, df2.orange_role)\n        self.assertEqual(df.orange_attributes, df2.orange_attributes)\n        self.assertEqual(df.orange_weights, df2.orange_weights)\n\n    def test_concat_table(self):\n        domain2 = Domain(\n            [self.table.domain['c2'],\n             self.table.domain['d1']]\n        )\n        table2 = Table.from_numpy(\n            domain2,\n            np.array(\n                [[0, 0],\n                 [1, 1]]),\n            W=np.array([1, 1])\n        )\n\n        df = self.table.X_df\n        df2 = table2.X_df\n        df3 = pd.concat([df, df2])\n        table3 = df3.to_orange_table()\n\n        np.testing.assert_array_equal(table3.ids,\n                                      np.concatenate([self.table.ids,\n                                                      table2.ids]))\n        np.testing.assert_array_equal(table3.W[:-2],\n                                      self.table.W)\n        np.testing.assert_array_equal(table3.W[-2:],\n                                      table2.W)\n\n        attrs = {}\n        attrs.update(self.table.attributes)\n        attrs.update(table2.attributes)\n\n        self.assertEqual(table3.attributes, attrs)\n\n        vars1 = self.table.domain.variables\n        vars2 = table3.domain.variables\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_concat_df(self):\n        df2 = pd.DataFrame(np.array([[0, 0],\n                                     [1, 1]]))\n\n        df = self.table.X_df\n        df3 = pd.concat([df, df2])\n        table3 = df3.to_orange_table()\n\n        np.testing.assert_array_equal(table3.ids[:-2],\n                                      self.table.ids)\n\n        d1 = self.table.domain\n        d2 = table3.domain\n\n        vars1 = d1.attributes\n        vars2 = d2.variables + d2.metas\n\n        for v1 in vars1:\n            self.assertIn(v1, vars2)\n\n    def test_merge(self):\n        domain2 = Domain(\n            [ContinuousVariable(\"c2\"),\n             ContinuousVariable(\"d15\")]\n        )\n        table2 = Table.from_numpy(\n            domain2,\n            np.array(\n                [[0, 4],\n                 [-1, 15],\n                 [1, 23]])\n        )\n\n        df = self.table.X_df\n        df2 = table2.X_df\n        df3 = pd.merge(df, df2, on='c2')\n        table2 = df.to_orange_table()\n        table3 = df3.to_orange_table()\n\n        self.assertEqual(len(table2), len(table3))\n        self.assertEqual(0, table3.W.size)\n        self.assertEqual(self.table.attributes, table3.attributes)\n\n        d1 = table2.domain\n        d2 = table3.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        self.assertEqual(len(vars2), len(vars1) + 1)\n\n        new_var = next(v for v in vars2\n                       if v.name == 'd15')\n        self.assertIsInstance(new_var, ContinuousVariable)\n\n        new_var_excluded = [v for v in vars2\n                            if v != new_var]\n        for v1, v2 in zip(vars1, new_var_excluded):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_new_column(self):\n        df = self.table.X_df\n        table2 = df.to_orange_table()\n        df['new'] = np.array([0, 1, 0, 1, 6, 1, 1])\n        table3 = df.to_orange_table()\n\n        d1 = table2.domain\n        d2 = table3.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        self.assertEqual(len(vars2), len(vars1) + 1)\n\n        new_var = next(v for v in vars2\n                       if v.name == 'new')\n        self.assertIsInstance(new_var, ContinuousVariable)\n\n        new_var_excluded = [v for v in vars2\n                            if v != new_var]\n        for v1, v2 in zip(vars1, new_var_excluded):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_selection(self):\n        df = self.table.X_df\n\n        tsel = self.table[1:3]\n        dfsel = df[1:3].to_orange_table()\n\n        self.__arreq__(tsel.X, dfsel.X)\n        self.__arreq__(tsel.ids, dfsel.ids)\n        self.__arreq__(tsel.W, dfsel.W)\n        self.__arreq__(tsel.attributes, dfsel.attributes)\n\n\nclass TestDenseTablePandas(TestTablePandas):\n    def setUp(self):\n        self.domain = Domain(\n            [ContinuousVariable(\"c1\"),\n             ContinuousVariable(\"c2\"),\n             DiscreteVariable(\"d1\", values=(\"a\", \"b\"))],\n            ContinuousVariable(\"y\"),\n            [ContinuousVariable(\"c3\"),\n             DiscreteVariable(\"d2\", values=(\"c\", \"d\")),\n             StringVariable(\"s1\"),\n             StringVariable(\"s2\")]\n        )\n        metas = np.array(\n            [0, 1, 0, 1, 1, 2, 1] +\n            [0, 0, 0, 0, 4, 1, 1] +\n            \"a  b  c  d  e     f    g\".split() +\n            list(\"ABCDEF\") + [\"\"], dtype=object).reshape(-1, 7).T.copy()\n        self.table = Table.from_numpy(\n            self.domain,\n            np.array(\n                [[0, 0, 0],\n                 [0, -1, 0],\n                 [7, 1, 0],\n                 [1, 1, 1],\n                 [1, 1, 1],\n                 [1, 1, 1],\n                 [1, 1, 1]]),\n            np.array(\n                [0, 1, 0, 1, 1, 1, 1]),\n            metas,\n            attributes={'haha': 'hoho'},\n            W=np.array([0, 1, 1, 0, 1, 0, 1])\n        )\n\n        self.__arreq__ = np.testing.assert_equal\n\n    def test_contiguous_x(self):\n        table = self.table\n        df = table.X_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.X))\n        self.assertTrue(np.shares_memory(df.values, table2.X))\n\n    def test_contiguous_y(self):\n        table = self.table\n        df = table.Y_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.Y))\n        self.assertTrue(np.shares_memory(df.values, table2.Y))\n\n    @unittest.skipUnless(pd.__version__ >= '1.4.0',\n                         'pandas-dev/pandas#39263')\n    def test_contiguous_metas(self):\n        table = self.table\n        df = table.metas_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.metas))\n        self.assertTrue(np.shares_memory(df.values, table2.metas))\n\n    def test_to_dfs(self):\n        table = self.table\n        dfs = table.to_pandas_dfs()\n\n        tables = [df.to_orange_table() for df in dfs]\n        for t in tables:\n            arrs = (t.X, t.Y, t.metas)\n            self.assertEqual(sum(\n                arr.size > 0\n                for arr in arrs\n            ), 1)\n\n    def test_amend(self):\n        with self.table.unlocked():\n            df = self.table.X_df\n            df.iloc[0][0] = 0\n        X = self.table.X\n        with self.table.unlocked():\n            self.table.X_df = df\n        self.assertTrue(np.shares_memory(df.values, X))\n\n    def test_amend_dimension_mismatch(self):\n        df = self.table.X_df\n        df = df.append([0, 1])\n        try:\n            self.table.X_df = df\n        except ValueError as e:\n            self.assertEqual(str(e),\n                             'Leading dimension mismatch (not 7 == 9)')\n        else:\n            self.fail()\n\n\nclass TestSparseTablePandas(TestTablePandas):\n    features = (\n        ContinuousVariable(name=\"c2\"),\n        ContinuousVariable(name=\"Continuous Feature 2\"),\n        DiscreteVariable(name=\"d1\", values=(\"0\", \"1\")),\n        DiscreteVariable(name=\"Discrete Feature 2\",\n                         values=(\"value1\", \"value2\")),\n    )\n\n    class_vars = (\n        ContinuousVariable(name=\"Continuous Class\"),\n        DiscreteVariable(name=\"Discrete Class\", values=(\"m\", \"f\"))\n    )\n\n    feature_data = (\n        (1, 0, 0, 0),\n        (0, 1, 0, 0),\n        (0, 1, 1, 0),\n        (0, 0, 0, 0),\n        (0, 1, 1, 0),\n        (0, 0, 0, 0),\n        (0, 1, 1, 0),\n    )\n\n    class_data = (\n        (1, 0),\n        (0, 1),\n        (1, 0),\n        (0, 1),\n        (1, 0),\n        (0, 1),\n        (1, 0),\n    )\n\n    def setUp(self):\n        self.domain = Domain(attributes=self.features,\n                             class_vars=self.class_vars)\n        table = Table.from_numpy(\n            self.domain,\n            np.array(self.feature_data),\n            np.array(self.class_data),\n        )\n        self.table = Table.from_numpy(\n            self.domain,\n            csr_matrix(table.X),\n            csr_matrix(table.Y),\n            W=np.array([1, 0, 1, 0, 1, 1, 1])\n        )\n\n        def arreq(t1, t2):\n            if all(sp.issparse(t) for t in (t1, t2)):\n                return self.assertEqual((t1 != t2).nnz, 0)\n            else:\n                return np.array_equal(t1, t2)\n\n        self.__arreq__ = arreq\n\n    def test_to_dense(self):\n        df = self.table.X_df\n\n        self.assertIsInstance(df, OrangeDataFrame)\n\n        ddf = df.sparse.to_dense()\n        np.testing.assert_array_equal(df.index, ddf.index)\n        np.testing.assert_array_equal(df.orange_variables, ddf.orange_variables)\n        np.testing.assert_array_equal(df.orange_attributes, ddf.orange_attributes)\n        np.testing.assert_array_equal(df.orange_role, ddf.orange_role)\n        np.testing.assert_array_equal(df.orange_weights, ddf.orange_weights)\n\n        table = self.table.to_dense()\n        table2 = ddf.to_orange_table()\n\n        np.testing.assert_array_equal(table2.X, table.X)\n        np.testing.assert_array_equal(table2.ids, table.ids)\n        np.testing.assert_array_equal(table2.W, table.W)\n        np.testing.assert_array_equal(table2.attributes, table.attributes)\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "header": {
                "file": {
                    "path": "Orange/data/tests/test_pandas.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "4eb7371fc",
                "new_commit_hash": "22cbe313b",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/data/tests/test_pandas.py"
            },
            "plus_file": {
                "path": "b/Orange/data/tests/test_pandas.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 34,
                            "length": 10
                        },
                        "new_range": {
                            "start": 34,
                            "length": 9
                        },
                        "section": "class TestPandasCompat(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                                 [0, pd.Timestamp('1724-12-20').timestamp()],",
                                "type": "context"
                            },
                            {
                                "content": "                                 [0, pd.Timestamp('1724-12-20').timestamp()],",
                                "type": "context"
                            },
                            {
                                "content": "                                 [nan, nan]])",
                                "type": "context"
                            },
                            {
                                "content": "        np.testing.assert_equal(table.metas.tolist(), [['a'],",
                                "type": "deleted"
                            },
                            {
                                "content": "                                                       ['b'],",
                                "type": "deleted"
                            },
                            {
                                "content": "                                                       ['c'],",
                                "type": "deleted"
                            },
                            {
                                "content": "                                                       [nan]])",
                                "type": "deleted"
                            },
                            {
                                "content": "        np.testing.assert_equal(",
                                "type": "added"
                            },
                            {
                                "content": "            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]",
                                "type": "added"
                            },
                            {
                                "content": "        )",
                                "type": "added"
                            },
                            {
                                "content": "        names = [var.name for var in table.domain.attributes]",
                                "type": "context"
                            },
                            {
                                "content": "        types = [type(var) for var in table.domain.attributes]",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(names, ['1', '2'])",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "method",
                            "name": "TestPandasCompat.test_table_from_frame",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 23,
                            "end_lineno": 73,
                            "parent": {
                                "file_name": "Orange/data/tests/test_pandas.py",
                                "type": "class",
                                "name": "TestPandasCompat",
                                "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 22,
                                "end_lineno": 510,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "class",
                            "name": "TestPandasCompat",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 22,
                            "end_lineno": 510,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 63,
                            "length": 10
                        },
                        "new_range": {
                            "start": 62,
                            "length": 9
                        },
                        "section": "class TestPandasCompat(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],",
                                "type": "context"
                            },
                            {
                                "content": "                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],",
                                "type": "context"
                            },
                            {
                                "content": "                                 [0, nan, nan]])",
                                "type": "context"
                            },
                            {
                                "content": "        np.testing.assert_equal(table.metas.tolist(), [['a'],",
                                "type": "deleted"
                            },
                            {
                                "content": "                                                       ['b'],",
                                "type": "deleted"
                            },
                            {
                                "content": "                                                       ['c'],",
                                "type": "deleted"
                            },
                            {
                                "content": "                                                       [nan]])",
                                "type": "deleted"
                            },
                            {
                                "content": "        np.testing.assert_equal(",
                                "type": "added"
                            },
                            {
                                "content": "            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]",
                                "type": "added"
                            },
                            {
                                "content": "        )",
                                "type": "added"
                            },
                            {
                                "content": "        names = [var.name for var in table.domain.attributes]",
                                "type": "context"
                            },
                            {
                                "content": "        types = [type(var) for var in table.domain.attributes]",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(names, ['index', '1', '2'])",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "method",
                            "name": "TestPandasCompat.test_table_from_frame",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 23,
                            "end_lineno": 73,
                            "parent": {
                                "file_name": "Orange/data/tests/test_pandas.py",
                                "type": "class",
                                "name": "TestPandasCompat",
                                "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 22,
                                "end_lineno": 510,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "class",
                            "name": "TestPandasCompat",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 22,
                            "end_lineno": 510,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 383,
                            "length": 7
                        },
                        "new_range": {
                            "start": 381,
                            "length": 7
                        },
                        "section": "class TestPandasCompat(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            ],",
                                "type": "context"
                            },
                            {
                                "content": "        )",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_table_from_frame_no_datetim(self):",
                                "type": "deleted"
                            },
                            {
                                "content": "    def test_table_from_frame_no_datetime(self):",
                                "type": "added"
                            },
                            {
                                "content": "        \"\"\"",
                                "type": "context"
                            },
                            {
                                "content": "        In case when dtype of column is object and column contains numbers only,",
                                "type": "context"
                            },
                            {
                                "content": "        column could be recognized as a TimeVarialbe since pd.to_datetime can parse",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "class",
                            "name": "TestPandasCompat",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 22,
                            "end_lineno": 510,
                            "parent": null
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "method",
                            "name": "TestPandasCompat.test_table_from_frame_no_datetime",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetime(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n            table.metas,\n        )\n        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 384,
                            "end_lineno": 401,
                            "parent": {
                                "file_name": "Orange/data/tests/test_pandas.py",
                                "type": "class",
                                "name": "TestPandasCompat",
                                "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetime(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n            table.metas,\n        )\n        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 22,
                                "end_lineno": 536,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": [
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "method",
                            "name": "TestPandasCompat.test_table_from_frame_no_datetim",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 386,
                            "end_lineno": 403,
                            "parent": {
                                "file_name": "Orange/data/tests/test_pandas.py",
                                "type": "class",
                                "name": "TestPandasCompat",
                                "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [['a'],\n                                                       ['b'],\n                                                       ['c'],\n                                                       [nan]])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetim(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 22,
                                "end_lineno": 510,
                                "parent": null
                            }
                        }
                    ]
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 402,
                            "length": 6
                        },
                        "new_range": {
                            "start": 400,
                            "length": 34
                        },
                        "section": "class TestPandasCompat(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        # check if exactly ContinuousVariable and not subtype TimeVariable",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def testa_table_from_frame_string(self):",
                                "type": "added"
                            },
                            {
                                "content": "        \"\"\"",
                                "type": "added"
                            },
                            {
                                "content": "        Test if string-like variables are handled correctly and nans are replaced",
                                "type": "added"
                            },
                            {
                                "content": "        with String.Unknown",
                                "type": "added"
                            },
                            {
                                "content": "        \"\"\"",
                                "type": "added"
                            },
                            {
                                "content": "        from Orange.data.pandas_compat import table_from_frame",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        # s1 contains nan and s2 contains pd.Na",
                                "type": "added"
                            },
                            {
                                "content": "        df = pd.DataFrame(",
                                "type": "added"
                            },
                            {
                                "content": "            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],",
                                "type": "added"
                            },
                            {
                                "content": "            columns=[\"s1\", \"s2\"],",
                                "type": "added"
                            },
                            {
                                "content": "        ).astype({\"s1\": \"object\", \"s2\": \"string\"})",
                                "type": "added"
                            },
                            {
                                "content": "        table = table_from_frame(df)",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_array_equal(np.empty((5, 0)), table.X)",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_array_equal(",
                                "type": "added"
                            },
                            {
                                "content": "            np.array(",
                                "type": "added"
                            },
                            {
                                "content": "                [",
                                "type": "added"
                            },
                            {
                                "content": "                    [\"a\", \"b\"],",
                                "type": "added"
                            },
                            {
                                "content": "                    [\"c\", \"d\"],",
                                "type": "added"
                            },
                            {
                                "content": "                    [\"e\", \"f\"],",
                                "type": "added"
                            },
                            {
                                "content": "                    [\"5\", \"c\"],",
                                "type": "added"
                            },
                            {
                                "content": "                    [StringVariable.Unknown, StringVariable.Unknown],",
                                "type": "added"
                            },
                            {
                                "content": "                ]",
                                "type": "added"
                            },
                            {
                                "content": "            ),",
                                "type": "added"
                            },
                            {
                                "content": "            table.metas,",
                                "type": "added"
                            },
                            {
                                "content": "        )",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    def test_time_variable_compatible(self):",
                                "type": "context"
                            },
                            {
                                "content": "        from Orange.data.pandas_compat import table_from_frame",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "class",
                            "name": "TestPandasCompat",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetime(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n            table.metas,\n        )\n        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 22,
                            "end_lineno": 536,
                            "parent": null
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "Orange/data/tests/test_pandas.py",
                            "type": "method",
                            "name": "TestPandasCompat.testa_table_from_frame_string",
                            "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetime(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n            table.metas,\n        )\n        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 403,
                            "end_lineno": 429,
                            "parent": {
                                "file_name": "Orange/data/tests/test_pandas.py",
                                "type": "class",
                                "name": "TestPandasCompat",
                                "content": "class TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetime(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n            table.metas,\n        )\n        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 22,
                                "end_lineno": 536,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "f7b522fecc65f63a330624ddcaeea8ac64e65781^",
    "new_commit_hash": "f7b522fecc65f63a330624ddcaeea8ac64e65781",
    "commit_message": "Merge pull request #5795 from PrimozGodec/pd-nans-string\n\n[FIX] table_from_frame: replace nan with String.Unknown for string variable",
    "commit_date": "2022-01-19T12:36:59+01:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "f7b522fecc65f63a330624ddcaeea8ac64e65781",
    "test_file_codes": [
        "# pylint: disable=import-outside-toplevel\nimport unittest\nfrom datetime import date, datetime, timezone\n\nimport numpy as np\nimport pytz\nfrom scipy.sparse import csr_matrix\nimport scipy.sparse as sp\n\nfrom Orange.data import ContinuousVariable, DiscreteVariable, TimeVariable, Table, Domain, \\\n    StringVariable\nfrom Orange.data.pandas_compat import OrangeDataFrame\nfrom Orange.data.tests.test_variable import TestTimeVariable\n\ntry:\n    import pandas as pd\nexcept ImportError:\n    pd = None\n\n\n@unittest.skipIf(pd is None, \"Missing package 'pandas'\")\nclass TestPandasCompat(unittest.TestCase):\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['1', '2'])\n        self.assertEqual(types, [ContinuousVariable, TimeVariable])\n\n        # Force strings nominal\n        table = table_from_frame(df, force_nominal=True)\n        np.testing.assert_equal(table.X, [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                          [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [2, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                          [nan, nan, nan]])\n        np.testing.assert_equal(table.metas.tolist(), [[], [], [], []])\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['0', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n        # Include index\n        df.index = list('abaa')\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[0, 1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [1, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, 0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, nan, nan]])\n        np.testing.assert_equal(\n            table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\n        names = [var.name for var in table.domain.attributes]\n        types = [type(var) for var in table.domain.attributes]\n        self.assertEqual(names, ['index', '1', '2'])\n        self.assertEqual(types, [DiscreteVariable, ContinuousVariable, TimeVariable])\n\n    def test_table_from_frame_keep_ids(self):\n        \"\"\" Test if indices are correctly transferred to Table\"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n        df = OrangeDataFrame(Table('iris')[:6])\n        df.index = [1, \"_oa\", \"_o\", \"1\", \"_o20\", \"_o30\"]\n        table = table_from_frame(df)\n        self.assertEqual(table.ids[-2:].tolist(), [20, 30])\n        self.assertTrue(np.issubdtype(table.ids.dtype, np.number))\n\n    def test_table_to_frame(self):\n        from Orange.data.pandas_compat import table_to_frame\n        table = Table(\"iris\")\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(type(df['iris'].dtype), pd.api.types.CategoricalDtype)\n        self.assertEqual(list(df['sepal length'])[0:4], [5.1, 4.9, 4.7, 4.6])\n        self.assertEqual(list(df['iris'])[0:2], ['Iris-setosa', 'Iris-setosa'])\n\n    def test_table_to_frame_object_dtype(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        domain = Domain([], metas=[ContinuousVariable(\"a\", number_of_decimals=0)])\n        table = Table.from_numpy(\n            domain, np.empty((10, 0)), metas=np.ones((10, 1), dtype=object)\n        )\n\n        df = table_to_frame(table, include_metas=True)\n        self.assertEqual([\"a\"], df.columns)\n        np.testing.assert_array_equal(df[\"a\"].values, np.ones((10,)))\n\n    def test_table_to_frame_nans(self):\n        from Orange.data.pandas_compat import table_to_frame\n        domain = Domain(\n            [ContinuousVariable(\"a\", number_of_decimals=0), ContinuousVariable(\"b\")]\n        )\n        table = Table(\n            domain, np.column_stack((np.ones(10), np.hstack((np.ones(9), [np.nan]))))\n        )\n\n        df = table_to_frame(table)\n        table_column_names = [var.name for var in table.domain.variables]\n        frame_column_names = df.columns\n\n        self.assertEqual(sorted(table_column_names), sorted(frame_column_names))\n        self.assertEqual(df[\"a\"].dtype, int)\n        self.assertEqual(df[\"b\"].dtype, float)\n        self.assertEqual([1, 1, 1], list(df[\"a\"].iloc[-3:]))\n        self.assertTrue(np.isnan(df[\"b\"].iloc[-1]))\n\n    def test_table_to_frame_metas(self):\n        from Orange.data.pandas_compat import table_to_frame\n\n        table = Table(\"zoo\")\n        domain = table.domain\n\n        df = table_to_frame(table)\n        cols = pd.Index([var.name for var in domain.variables])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n        df = table_to_frame(table, include_metas=True)\n        cols = pd.Index([var.name for var in domain.variables + domain.metas])\n        pd.testing.assert_index_equal(df.columns, cols)\n\n    def test_not_orangedf(self):\n        table = Table(\"iris\")\n        xdf, ydf, mdf = table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        np.testing.assert_array_equal(table.X, xtable.X)\n        np.testing.assert_array_equal(table.Y, ytable.Y)\n        np.testing.assert_array_equal(table.metas, mtable.metas)\n        np.testing.assert_array_equal(table.W, xtable.W)\n        np.testing.assert_array_equal(table.W, ytable.W)\n        np.testing.assert_array_equal(table.W, mtable.W)\n        self.assertEqual(table.attributes, xtable.attributes)\n        self.assertEqual(table.attributes, ytable.attributes)\n        self.assertEqual(table.attributes, mtable.attributes)\n        np.testing.assert_array_equal(table.ids, xtable.ids)\n        np.testing.assert_array_equal(table.ids, ytable.ids)\n        np.testing.assert_array_equal(table.ids, mtable.ids)\n\n        d1 = table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_table_from_frame_date(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"2017-12-19\")], [pd.Timestamp(\"1724-12-20\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[\"2017-12-19\"], [\"1724-12-20\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame([[date(2017, 12, 19)], [date(1724, 12, 20)], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19\").timestamp()],\n                [pd.Timestamp(\"1724-12-20\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 0)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_time(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [[pd.Timestamp(\"00:00:00.25\")], [pd.Timestamp(\"20:20:20.30\")], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n        df = pd.DataFrame([[\"00:00:00.25\"], [\"20:20:20.30\"], [np.nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"1970-01-01 00:00:00.25\").timestamp()],\n                [pd.Timestamp(\"1970-01-01 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 0)\n\n    def test_table_from_frame_datetime(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [[\"2017-12-19 00:00:00.50\"], [\"1724-12-20 20:20:20.30\"], [np.nan]]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n        df = pd.DataFrame(\n            [\n                [datetime(2017, 12, 19, 0, 0, 0, 500000)],\n                [datetime(1724, 12, 20, 20, 20, 20, 300000)],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00.50\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20.30\").timestamp()],\n                [np.nan],\n            ],\n        )\n        self.assertEqual(table.domain.variables[0].have_time, 1)\n        self.assertEqual(table.domain.variables[0].have_date, 1)\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n\n    def test_table_from_frame_no_datetime(self):\n        \"\"\"\n        In case when dtype of column is object and column contains numbers only,\n        column could be recognized as a TimeVarialbe since pd.to_datetime can parse\n        numbers as datetime. That column must be result either in StringVariable\n        or DiscreteVariable since it's dtype is object.\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        df = pd.DataFrame([[1], [2], [3]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.metas[0], StringVariable)\n\n        df = pd.DataFrame([[1], [2], [2]], dtype=\"object\")\n        table = table_from_frame(df)\n        # check if exactly ContinuousVariable and not subtype TimeVariable\n        self.assertIsInstance(table.domain.attributes[0], DiscreteVariable)\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n\n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n            table.metas,\n        )\n        self.assertTrue(all(isinstance(v, StringVariable) for v in table.domain.metas))\n\n    def test_time_variable_compatible(self):\n        from Orange.data.pandas_compat import table_from_frame\n\n        def to_df(val):\n            return pd.DataFrame([[pd.Timestamp(val)]])\n\n        for datestr, timestamp, outstr in TestTimeVariable.TESTS:\n            var = TimeVariable(\"time\")\n            var_parse = var.to_val(datestr)\n            try:\n                pandas_parse = table_from_frame(to_df(datestr)).X[0, 0]\n            except ValueError:\n                # pandas cannot parse some formats in the list skip them\n                continue\n            if not (np.isnan(var_parse) and np.isnan(pandas_parse)):\n                # nan == nan => False\n                self.assertEqual(var_parse, pandas_parse)\n                self.assertEqual(pandas_parse, timestamp)\n\n            self.assertEqual(var.repr_val(var_parse), var.repr_val(var_parse))\n            self.assertEqual(outstr, var.repr_val(var_parse))\n\n    @unittest.skip(\"Convert all Orange demo dataset. It takes about 5s which is way to slow\")\n    def test_table_to_frame_on_all_orange_dataset(self):\n        from os import listdir\n        from Orange.data.pandas_compat import table_to_frame\n\n        dataset_directory = \"Orange/datasets/\"\n\n        def _filename_to_dataset_name(f):\n            return f.split('.')[0]\n\n        def _get_orange_demo_datasets():\n            x = [_filename_to_dataset_name(f) for f in listdir(dataset_directory) if '.tab' in f]\n            return x\n\n        for name in _get_orange_demo_datasets():\n            table = Table(name)\n            df = table_to_frame(table)\n            assert_message = \"Failed to process Table('{}')\".format(name)\n\n            self.assertEqual(type(df), pd.DataFrame, assert_message)\n            self.assertEqual(len(df), len(table), assert_message)\n            self.assertEqual(len(df.columns), len(table.domain.variables), assert_message)\n\n    def test_table_from_frames(self):\n        table = Table(\"brown-selected\")  # dataset with all X, Y and metas\n        table.ids = np.arange(100, len(table) + 100, 1, dtype=int)\n\n        x, y, m = table.to_pandas_dfs()\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(table.X, new_table.X)\n        np.testing.assert_array_equal(table.Y, new_table.Y)\n        np.testing.assert_array_equal(table.metas, new_table.metas)\n        np.testing.assert_array_equal(table.ids, new_table.ids)\n        self.assertTupleEqual(table.domain.attributes, new_table.domain.attributes)\n        self.assertTupleEqual(table.domain.metas, new_table.domain.metas)\n        self.assertEqual(table.domain.class_var, new_table.domain.class_var)\n\n    def test_table_from_frames_not_orange_dataframe(self):\n        x = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"])\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"])\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"])\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(m, new_table.metas)\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual(m.columns.tolist(), [a.name for a in d.metas])\n\n    def test_table_from_frames_same_index(self):\n        \"\"\"\n        Test that index column is placed in metas. Function should fail\n        with ValueError when indexes are different\n        \"\"\"\n        index = np.array([\"a\", \"b\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        new_table = Table.from_pandas_dfs(x, y, m)\n\n        # index should be placed in metas\n        np.testing.assert_array_equal(x, new_table.X)\n        np.testing.assert_array_equal(y.values.flatten(), new_table.Y)\n        np.testing.assert_array_equal(\n            np.hstack((index[:, None], m.values.astype(\"object\"))), new_table.metas\n        )\n        d = new_table.domain\n        self.assertListEqual(x.columns.tolist(), [a.name for a in d.attributes])\n        self.assertEqual(y.columns[0], d.class_var.name)\n        self.assertListEqual([\"index\"] + m.columns.tolist(), [a.name for a in d.metas])\n\n        index2 = np.array([\"a\", \"c\"])\n        x = pd.DataFrame(\n            [[1, 2, 3], [4, 5, 6]], columns=[\"x1\", \"x2\", \"x3\"], index=index\n        )\n        y = pd.DataFrame([[5], [6]], columns=[\"y\"], index=index2)\n        m = pd.DataFrame([[1, 2], [4, 5]], columns=[\"m1\", \"m2\"], index=index)\n        with self.assertRaises(ValueError):\n            Table.from_pandas_dfs(x, y, m)\n\n\nclass TestTablePandas(unittest.TestCase):\n    def setUp(self):\n        if not hasattr(self, 'table'):\n            self.skipTest('Base class')\n\n    def test_basic(self):\n        xdf, ydf, mdf = self.table.to_pandas_dfs()\n        xtable = xdf.to_orange_table()\n        ytable = ydf.to_orange_table()\n        mtable = mdf.to_orange_table()\n\n        self.__arreq__(self.table.X, xtable.X)\n        self.__arreq__(self.table.Y, ytable.Y)\n        self.__arreq__(self.table.metas, mtable.metas)\n        self.__arreq__(self.table.W, xtable.W)\n        self.__arreq__(self.table.W, ytable.W)\n        self.__arreq__(self.table.W, mtable.W)\n        self.assertEqual(self.table.attributes, xtable.attributes)\n        self.assertEqual(self.table.attributes, ytable.attributes)\n        self.assertEqual(self.table.attributes, mtable.attributes)\n        self.__arreq__(self.table.ids, xtable.ids)\n        self.__arreq__(self.table.ids, ytable.ids)\n        self.__arreq__(self.table.ids, mtable.ids)\n\n        d1 = self.table.domain\n        d2 = xtable.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_slice(self):\n        df = self.table.X_df\n        table2 = df[['c2', 'd1']].to_orange_table()\n\n        self.__arreq__(self.table.ids, table2.ids)\n        self.__arreq__(self.table.W, table2.W)\n        self.__arreq__(self.table.attributes, table2.attributes)\n\n        domain = table2.domain\n        target_domain = Domain([ContinuousVariable(\"c2\"),\n                                DiscreteVariable(\"d1\")])\n\n        self.assertEqual(domain, target_domain)\n\n    def test_copy(self):\n        df = self.table.X_df\n        df2 = df.copy()\n\n        np.testing.assert_array_equal(df.index, df2.index)\n        self.assertEqual(df.orange_variables, df2.orange_variables)\n        self.assertEqual(df.orange_role, df2.orange_role)\n        self.assertEqual(df.orange_attributes, df2.orange_attributes)\n        self.assertEqual(df.orange_weights, df2.orange_weights)\n\n    def test_concat_table(self):\n        domain2 = Domain(\n            [self.table.domain['c2'],\n             self.table.domain['d1']]\n        )\n        table2 = Table.from_numpy(\n            domain2,\n            np.array(\n                [[0, 0],\n                 [1, 1]]),\n            W=np.array([1, 1])\n        )\n\n        df = self.table.X_df\n        df2 = table2.X_df\n        df3 = pd.concat([df, df2])\n        table3 = df3.to_orange_table()\n\n        np.testing.assert_array_equal(table3.ids,\n                                      np.concatenate([self.table.ids,\n                                                      table2.ids]))\n        np.testing.assert_array_equal(table3.W[:-2],\n                                      self.table.W)\n        np.testing.assert_array_equal(table3.W[-2:],\n                                      table2.W)\n\n        attrs = {}\n        attrs.update(self.table.attributes)\n        attrs.update(table2.attributes)\n\n        self.assertEqual(table3.attributes, attrs)\n\n        vars1 = self.table.domain.variables\n        vars2 = table3.domain.variables\n\n        for v1, v2 in zip(vars1, vars2):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_concat_df(self):\n        df2 = pd.DataFrame(np.array([[0, 0],\n                                     [1, 1]]))\n\n        df = self.table.X_df\n        df3 = pd.concat([df, df2])\n        table3 = df3.to_orange_table()\n\n        np.testing.assert_array_equal(table3.ids[:-2],\n                                      self.table.ids)\n\n        d1 = self.table.domain\n        d2 = table3.domain\n\n        vars1 = d1.attributes\n        vars2 = d2.variables + d2.metas\n\n        for v1 in vars1:\n            self.assertIn(v1, vars2)\n\n    def test_merge(self):\n        domain2 = Domain(\n            [ContinuousVariable(\"c2\"),\n             ContinuousVariable(\"d15\")]\n        )\n        table2 = Table.from_numpy(\n            domain2,\n            np.array(\n                [[0, 4],\n                 [-1, 15],\n                 [1, 23]])\n        )\n\n        df = self.table.X_df\n        df2 = table2.X_df\n        df3 = pd.merge(df, df2, on='c2')\n        table2 = df.to_orange_table()\n        table3 = df3.to_orange_table()\n\n        self.assertEqual(len(table2), len(table3))\n        self.assertEqual(0, table3.W.size)\n        self.assertEqual(self.table.attributes, table3.attributes)\n\n        d1 = table2.domain\n        d2 = table3.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        self.assertEqual(len(vars2), len(vars1) + 1)\n\n        new_var = next(v for v in vars2\n                       if v.name == 'd15')\n        self.assertIsInstance(new_var, ContinuousVariable)\n\n        new_var_excluded = [v for v in vars2\n                            if v != new_var]\n        for v1, v2 in zip(vars1, new_var_excluded):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_new_column(self):\n        df = self.table.X_df\n        table2 = df.to_orange_table()\n        df['new'] = np.array([0, 1, 0, 1, 6, 1, 1])\n        table3 = df.to_orange_table()\n\n        d1 = table2.domain\n        d2 = table3.domain\n\n        vars1 = d1.variables + d1.metas\n        vars2 = d2.variables + d2.metas\n\n        self.assertEqual(len(vars2), len(vars1) + 1)\n\n        new_var = next(v for v in vars2\n                       if v.name == 'new')\n        self.assertIsInstance(new_var, ContinuousVariable)\n\n        new_var_excluded = [v for v in vars2\n                            if v != new_var]\n        for v1, v2 in zip(vars1, new_var_excluded):\n            self.assertEqual(type(v1), type(v2))\n\n    def test_selection(self):\n        df = self.table.X_df\n\n        tsel = self.table[1:3]\n        dfsel = df[1:3].to_orange_table()\n\n        self.__arreq__(tsel.X, dfsel.X)\n        self.__arreq__(tsel.ids, dfsel.ids)\n        self.__arreq__(tsel.W, dfsel.W)\n        self.__arreq__(tsel.attributes, dfsel.attributes)\n\n\nclass TestDenseTablePandas(TestTablePandas):\n    def setUp(self):\n        self.domain = Domain(\n            [ContinuousVariable(\"c1\"),\n             ContinuousVariable(\"c2\"),\n             DiscreteVariable(\"d1\", values=(\"a\", \"b\"))],\n            ContinuousVariable(\"y\"),\n            [ContinuousVariable(\"c3\"),\n             DiscreteVariable(\"d2\", values=(\"c\", \"d\")),\n             StringVariable(\"s1\"),\n             StringVariable(\"s2\")]\n        )\n        metas = np.array(\n            [0, 1, 0, 1, 1, 2, 1] +\n            [0, 0, 0, 0, 4, 1, 1] +\n            \"a  b  c  d  e     f    g\".split() +\n            list(\"ABCDEF\") + [\"\"], dtype=object).reshape(-1, 7).T.copy()\n        self.table = Table.from_numpy(\n            self.domain,\n            np.array(\n                [[0, 0, 0],\n                 [0, -1, 0],\n                 [7, 1, 0],\n                 [1, 1, 1],\n                 [1, 1, 1],\n                 [1, 1, 1],\n                 [1, 1, 1]]),\n            np.array(\n                [0, 1, 0, 1, 1, 1, 1]),\n            metas,\n            attributes={'haha': 'hoho'},\n            W=np.array([0, 1, 1, 0, 1, 0, 1])\n        )\n\n        self.__arreq__ = np.testing.assert_equal\n\n    def test_contiguous_x(self):\n        table = self.table\n        df = table.X_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.X))\n        self.assertTrue(np.shares_memory(df.values, table2.X))\n\n    def test_contiguous_y(self):\n        table = self.table\n        df = table.Y_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.Y))\n        self.assertTrue(np.shares_memory(df.values, table2.Y))\n\n    @unittest.skipUnless(pd.__version__ >= '1.4.0',\n                         'pandas-dev/pandas#39263')\n    def test_contiguous_metas(self):\n        table = self.table\n        df = table.metas_df\n        table2 = df.to_orange_table()\n        self.assertTrue(np.shares_memory(df.values, table.metas))\n        self.assertTrue(np.shares_memory(df.values, table2.metas))\n\n    def test_to_dfs(self):\n        table = self.table\n        dfs = table.to_pandas_dfs()\n\n        tables = [df.to_orange_table() for df in dfs]\n        for t in tables:\n            arrs = (t.X, t.Y, t.metas)\n            self.assertEqual(sum(\n                arr.size > 0\n                for arr in arrs\n            ), 1)\n\n    def test_amend(self):\n        with self.table.unlocked():\n            df = self.table.X_df\n            df.iloc[0][0] = 0\n        X = self.table.X\n        with self.table.unlocked():\n            self.table.X_df = df\n        self.assertTrue(np.shares_memory(df.values, X))\n\n    def test_amend_dimension_mismatch(self):\n        df = self.table.X_df\n        df = df.append([0, 1])\n        try:\n            self.table.X_df = df\n        except ValueError as e:\n            self.assertEqual(str(e),\n                             'Leading dimension mismatch (not 7 == 9)')\n        else:\n            self.fail()\n\n\nclass TestSparseTablePandas(TestTablePandas):\n    features = (\n        ContinuousVariable(name=\"c2\"),\n        ContinuousVariable(name=\"Continuous Feature 2\"),\n        DiscreteVariable(name=\"d1\", values=(\"0\", \"1\")),\n        DiscreteVariable(name=\"Discrete Feature 2\",\n                         values=(\"value1\", \"value2\")),\n    )\n\n    class_vars = (\n        ContinuousVariable(name=\"Continuous Class\"),\n        DiscreteVariable(name=\"Discrete Class\", values=(\"m\", \"f\"))\n    )\n\n    feature_data = (\n        (1, 0, 0, 0),\n        (0, 1, 0, 0),\n        (0, 1, 1, 0),\n        (0, 0, 0, 0),\n        (0, 1, 1, 0),\n        (0, 0, 0, 0),\n        (0, 1, 1, 0),\n    )\n\n    class_data = (\n        (1, 0),\n        (0, 1),\n        (1, 0),\n        (0, 1),\n        (1, 0),\n        (0, 1),\n        (1, 0),\n    )\n\n    def setUp(self):\n        self.domain = Domain(attributes=self.features,\n                             class_vars=self.class_vars)\n        table = Table.from_numpy(\n            self.domain,\n            np.array(self.feature_data),\n            np.array(self.class_data),\n        )\n        self.table = Table.from_numpy(\n            self.domain,\n            csr_matrix(table.X),\n            csr_matrix(table.Y),\n            W=np.array([1, 0, 1, 0, 1, 1, 1])\n        )\n\n        def arreq(t1, t2):\n            if all(sp.issparse(t) for t in (t1, t2)):\n                return self.assertEqual((t1 != t2).nnz, 0)\n            else:\n                return np.array_equal(t1, t2)\n\n        self.__arreq__ = arreq\n\n    def test_to_dense(self):\n        df = self.table.X_df\n\n        self.assertIsInstance(df, OrangeDataFrame)\n\n        ddf = df.sparse.to_dense()\n        np.testing.assert_array_equal(df.index, ddf.index)\n        np.testing.assert_array_equal(df.orange_variables, ddf.orange_variables)\n        np.testing.assert_array_equal(df.orange_attributes, ddf.orange_attributes)\n        np.testing.assert_array_equal(df.orange_role, ddf.orange_role)\n        np.testing.assert_array_equal(df.orange_weights, ddf.orange_weights)\n\n        table = self.table.to_dense()\n        table2 = ddf.to_orange_table()\n\n        np.testing.assert_array_equal(table2.X, table.X)\n        np.testing.assert_array_equal(table2.ids, table.ids)\n        np.testing.assert_array_equal(table2.W, table.W)\n        np.testing.assert_array_equal(table2.attributes, table.attributes)\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Orange installation attempts...\nAttempting installation with Python 3.7...\nrunning build_ext\nCompiling Orange/classification/_tree_scorers.pyx because it changed.\nCompiling Orange/data/_contingency.pyx because it changed.\nCompiling Orange/data/_io.pyx because it changed.\nCompiling Orange/data/_valuecount.pyx because it changed.\nCompiling Orange/data/_variable.pyx because it changed.\nCompiling Orange/distance/_distance.pyx because it changed.\nCompiling Orange/preprocess/_discretize.pyx because it changed.\nCompiling Orange/preprocess/_relieff.pyx because it changed.\nCompiling Orange/projection/_som.pyx because it changed.\n[1/9] Cythonizing Orange/classification/_tree_scorers.pyx\n[2/9] Cythonizing Orange/data/_contingency.pyx\n[3/9] Cythonizing Orange/data/_io.pyx\n[4/9] Cythonizing Orange/data/_valuecount.pyx\n[5/9] Cythonizing Orange/data/_variable.pyx\n[6/9] Cythonizing Orange/distance/_distance.pyx\n[7/9] Cythonizing Orange/preprocess/_discretize.pyx\n[8/9] Cythonizing Orange/preprocess/_relieff.pyx\n[9/9] Cythonizing Orange/projection/_som.pyx\nbuilding 'Orange.classification._tree_scorers' extension\ncreating build\ncreating build/temp.linux-x86_64-3.7\ncreating build/temp.linux-x86_64-3.7/Orange\ncreating build/temp.linux-x86_64-3.7/Orange/classification\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_tree_scorers.c -o build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o\ncreating build/lib.linux-x86_64-3.7\ncreating build/lib.linux-x86_64-3.7/Orange\ncreating build/lib.linux-x86_64-3.7/Orange/classification\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._contingency' extension\ncreating build/temp.linux-x86_64-3.7/Orange/data\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_contingency.c -o build/temp.linux-x86_64-3.7/Orange/data/_contingency.o\ncreating build/lib.linux-x86_64-3.7/Orange/data\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_contingency.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._io' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_io.c -o build/temp.linux-x86_64-3.7/Orange/data/_io.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_io.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._valuecount' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_valuecount.c -o build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._variable' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_variable.c -o build/temp.linux-x86_64-3.7/Orange/data/_variable.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_variable.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.distance._distance' extension\ncreating build/temp.linux-x86_64-3.7/Orange/distance\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/distance/_distance.c -o build/temp.linux-x86_64-3.7/Orange/distance/_distance.o\ncreating build/lib.linux-x86_64-3.7/Orange/distance\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/distance/_distance.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._discretize' extension\ncreating build/temp.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_discretize.c -o build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o\ncreating build/lib.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._relieff' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_relieff.cpp -o build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.projection._som' extension\ncreating build/temp.linux-x86_64-3.7/Orange/projection\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/projection/_som.c -o build/temp.linux-x86_64-3.7/Orange/projection/_som.o\ncreating build/lib.linux-x86_64-3.7/Orange/projection\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/projection/_som.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.classification._simple_tree' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_simple_tree.c -o build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.widgets.utils._grid_density' extension\ncreating build/temp.linux-x86_64-3.7/Orange/widgets\ncreating build/temp.linux-x86_64-3.7/Orange/widgets/utils\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/widgets/utils/_grid_density.cpp -o build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o\ncreating build/lib.linux-x86_64-3.7/Orange/widgets\ncreating build/lib.linux-x86_64-3.7/Orange/widgets/utils\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nrunning develop\nrunning egg_info\ncreating Orange3.egg-info\nwriting Orange3.egg-info/PKG-INFO\nwriting dependency_links to Orange3.egg-info/dependency_links.txt\nwriting entry points to Orange3.egg-info/entry_points.txt\nwriting requirements to Orange3.egg-info/requires.txt\nwriting top-level names to Orange3.egg-info/top_level.txt\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest template 'MANIFEST.in'\nadding license file 'LICENSE'\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nrunning build_ext\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nCreating /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.32.0.dev0+f7b522f to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781\nProcessing dependencies for Orange3==3.32.0.dev0+f7b522f\nSearching for XlsxWriter==3.2.0\nBest match: XlsxWriter 3.2.0\nAdding XlsxWriter 3.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for xlrd==2.0.1\nBest match: xlrd 2.0.1\nAdding xlrd 2.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for setuptools==59.8.0\nBest match: setuptools 59.8.0\nAdding setuptools 59.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for serverfiles==0.3.1\nBest match: serverfiles 0.3.1\nAdding serverfiles 0.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for scipy==1.7.3\nBest match: scipy 1.7.3\nAdding scipy 1.7.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for scikit-learn==1.0.2\nBest match: scikit-learn 1.0.2\nAdding scikit-learn 1.0.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for requests==2.31.0\nBest match: requests 2.31.0\nAdding requests 2.31.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for qtconsole==5.4.4\nBest match: qtconsole 5.4.4\nAdding qtconsole 5.4.4 to easy-install.pth file\nInstalling jupyter-qtconsole script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for PyYAML==6.0.1\nBest match: PyYAML 6.0.1\nAdding PyYAML 6.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for python-louvain==0.16\nBest match: python-louvain 0.16\nAdding python-louvain 0.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pyqtgraph==0.12.4\nBest match: pyqtgraph 0.12.4\nAdding pyqtgraph 0.12.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pygments==2.17.2\nBest match: pygments 2.17.2\nAdding pygments 2.17.2 to easy-install.pth file\nInstalling pygmentize script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pip==24.0\nBest match: pip 24.0\nAdding pip 24.0 to easy-install.pth file\nInstalling pip script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pandas==1.3.5\nBest match: pandas 1.3.5\nAdding pandas 1.3.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for orange-widget-base==4.22.0\nBest match: orange-widget-base 4.22.0\nAdding orange-widget-base 4.22.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for orange-canvas-core==0.1.35\nBest match: orange-canvas-core 0.1.35\nAdding orange-canvas-core 0.1.35 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for openpyxl==3.1.3\nBest match: openpyxl 3.1.3\nAdding openpyxl 3.1.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for openTSNE==1.0.1\nBest match: openTSNE 1.0.1\nAdding openTSNE 1.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for numpy==1.17.5\nBest match: numpy 1.17.5\nAdding numpy 1.17.5 to easy-install.pth file\nInstalling f2py script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for networkx==2.6.3\nBest match: networkx 2.6.3\nAdding networkx 2.6.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for matplotlib==3.5.3\nBest match: matplotlib 3.5.3\nAdding matplotlib 3.5.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for keyrings.alt==4.2.0\nBest match: keyrings.alt 4.2.0\nAdding keyrings.alt 4.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for keyring==24.1.1\nBest match: keyring 24.1.1\nAdding keyring 24.1.1 to easy-install.pth file\nInstalling keyring script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for joblib==1.3.2\nBest match: joblib 1.3.2\nAdding joblib 1.3.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for httpx==0.19.0\nBest match: httpx 0.19.0\nAdding httpx 0.19.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for chardet==5.2.0\nBest match: chardet 5.2.0\nAdding chardet 5.2.0 to easy-install.pth file\nInstalling chardetect script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for Bottleneck==1.4.0\nBest match: Bottleneck 1.4.0\nAdding Bottleneck 1.4.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for baycomp==1.0.3\nBest match: baycomp 1.0.3\nAdding baycomp 1.0.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine==5.15.6\nBest match: PyQtWebEngine 5.15.6\nAdding PyQtWebEngine 5.15.6 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for PyQt5==5.15.10\nBest match: PyQt5 5.15.10\nAdding PyQt5 5.15.10 to easy-install.pth file\nInstalling pylupdate5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling pyrcc5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling pyuic5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for AnyQt==0.2.0\nBest match: AnyQt 0.2.0\nAdding AnyQt 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for threadpoolctl==3.1.0\nBest match: threadpoolctl 3.1.0\nAdding threadpoolctl 3.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for idna==3.10\nBest match: idna 3.10\nAdding idna 3.10 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for charset-normalizer==3.4.1\nBest match: charset-normalizer 3.4.1\nAdding charset-normalizer 3.4.1 to easy-install.pth file\nInstalling normalizer script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for certifi==2024.12.14\nBest match: certifi 2024.12.14\nAdding certifi 2024.12.14 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for urllib3==2.0.7\nBest match: urllib3 2.0.7\nAdding urllib3 2.0.7 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for jupyter-core==4.12.0\nBest match: jupyter-core 4.12.0\nAdding jupyter-core 4.12.0 to easy-install.pth file\nInstalling jupyter script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling jupyter-migrate script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling jupyter-troubleshoot script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for ipykernel==6.16.2\nBest match: ipykernel 6.16.2\nAdding ipykernel 6.16.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for jupyter-client==7.4.9\nBest match: jupyter-client 7.4.9\nAdding jupyter-client 7.4.9 to easy-install.pth file\nInstalling jupyter-kernel script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling jupyter-kernelspec script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling jupyter-run script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for QtPy==2.4.2\nBest match: QtPy 2.4.2\nAdding QtPy 2.4.2 to easy-install.pth file\nInstalling qtpy script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for packaging==24.0\nBest match: packaging 24.0\nAdding packaging 24.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for traitlets==5.9.0\nBest match: traitlets 5.9.0\nAdding traitlets 5.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pyzmq==26.2.0\nBest match: pyzmq 26.2.0\nAdding pyzmq 26.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for ipython-genutils==0.2.0\nBest match: ipython-genutils 0.2.0\nAdding ipython-genutils 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pytz==2024.2\nBest match: pytz 2024.2\nAdding pytz 2024.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for python-dateutil==2.9.0.post0\nBest match: python-dateutil 2.9.0.post0\nAdding python-dateutil 2.9.0.post0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for typing-extensions==4.7.1\nBest match: typing-extensions 4.7.1\nAdding typing-extensions 4.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for qasync==0.25.0\nBest match: qasync 0.25.0\nAdding qasync 0.25.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for commonmark==0.9.1\nBest match: commonmark 0.9.1\nAdding commonmark 0.9.1 to easy-install.pth file\nInstalling cmark script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for dictdiffer==0.9.0\nBest match: dictdiffer 0.9.0\nAdding dictdiffer 0.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for docutils==0.20.1\nBest match: docutils 0.20.1\nAdding docutils 0.20.1 to easy-install.pth file\nInstalling docutils script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for importlib-metadata==6.7.0\nBest match: importlib-metadata 6.7.0\nAdding importlib-metadata 6.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for requests-cache==1.1.1\nBest match: requests-cache 1.1.1\nAdding requests-cache 1.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for et-xmlfile==1.1.0\nBest match: et-xmlfile 1.1.0\nAdding et-xmlfile 1.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for kiwisolver==1.4.5\nBest match: kiwisolver 1.4.5\nAdding kiwisolver 1.4.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for cycler==0.11.0\nBest match: cycler 0.11.0\nAdding cycler 0.11.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for Pillow==9.5.0\nBest match: Pillow 9.5.0\nAdding Pillow 9.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pyparsing==3.1.4\nBest match: pyparsing 3.1.4\nAdding pyparsing 3.1.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for fonttools==4.38.0\nBest match: fonttools 4.38.0\nAdding fonttools 4.38.0 to easy-install.pth file\nInstalling fonttools script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for jaraco.classes==3.2.3\nBest match: jaraco.classes 3.2.3\nAdding jaraco.classes 3.2.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for jeepney==0.8.0\nBest match: jeepney 0.8.0\nAdding jeepney 0.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for importlib-resources==5.12.0\nBest match: importlib-resources 5.12.0\nAdding importlib-resources 5.12.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for SecretStorage==3.3.3\nBest match: SecretStorage 3.3.3\nAdding SecretStorage 3.3.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for sniffio==1.3.1\nBest match: sniffio 1.3.1\nAdding sniffio 1.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for rfc3986==1.5.0\nBest match: rfc3986 1.5.0\nAdding rfc3986 1.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for httpcore==0.13.7\nBest match: httpcore 0.13.7\nAdding httpcore 0.13.7 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine-Qt5==5.15.16\nBest match: PyQtWebEngine-Qt5 5.15.16\nAdding PyQtWebEngine-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for PyQt5-sip==12.13.0\nBest match: PyQt5-sip 12.13.0\nAdding PyQt5-sip 12.13.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for PyQt5-Qt5==5.15.16\nBest match: PyQt5-Qt5 5.15.16\nAdding PyQt5-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for nest-asyncio==1.6.0\nBest match: nest-asyncio 1.6.0\nAdding nest-asyncio 1.6.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for tornado==6.2\nBest match: tornado 6.2\nAdding tornado 6.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for matplotlib-inline==0.1.6\nBest match: matplotlib-inline 0.1.6\nAdding matplotlib-inline 0.1.6 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for debugpy==1.7.0\nBest match: debugpy 1.7.0\nAdding debugpy 1.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for ipython==7.34.0\nBest match: ipython 7.34.0\nAdding ipython 7.34.0 to easy-install.pth file\nInstalling iptest script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling iptest3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling ipython script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\nInstalling ipython3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for psutil==6.1.1\nBest match: psutil 6.1.1\nAdding psutil 6.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for entrypoints==0.4\nBest match: entrypoints 0.4\nAdding entrypoints 0.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for six==1.17.0\nBest match: six 1.17.0\nAdding six 1.17.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for zipp==3.15.0\nBest match: zipp 3.15.0\nAdding zipp 3.15.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for cattrs==23.1.2\nBest match: cattrs 23.1.2\nAdding cattrs 23.1.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for url-normalize==1.4.3\nBest match: url-normalize 1.4.3\nAdding url-normalize 1.4.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for attrs==24.2.0\nBest match: attrs 24.2.0\nAdding attrs 24.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for platformdirs==4.0.0\nBest match: platformdirs 4.0.0\nAdding platformdirs 4.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for more-itertools==9.1.0\nBest match: more-itertools 9.1.0\nAdding more-itertools 9.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for cryptography==44.0.0\nBest match: cryptography 44.0.0\nAdding cryptography 44.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for h11==0.12.0\nBest match: h11 0.12.0\nAdding h11 0.12.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for anyio==3.7.1\nBest match: anyio 3.7.1\nAdding anyio 3.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pickleshare==0.7.5\nBest match: pickleshare 0.7.5\nAdding pickleshare 0.7.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pexpect==4.9.0\nBest match: pexpect 4.9.0\nAdding pexpect 4.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for prompt-toolkit==3.0.48\nBest match: prompt-toolkit 3.0.48\nAdding prompt-toolkit 3.0.48 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for backcall==0.2.0\nBest match: backcall 0.2.0\nAdding backcall 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for jedi==0.19.2\nBest match: jedi 0.19.2\nAdding jedi 0.19.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for decorator==5.1.1\nBest match: decorator 5.1.1\nAdding decorator 5.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for exceptiongroup==1.2.2\nBest match: exceptiongroup 1.2.2\nAdding exceptiongroup 1.2.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for cffi==1.15.1\nBest match: cffi 1.15.1\nAdding cffi 1.15.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for ptyprocess==0.7.0\nBest match: ptyprocess 0.7.0\nAdding ptyprocess 0.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for wcwidth==0.2.13\nBest match: wcwidth 0.2.13\nAdding wcwidth 0.2.13 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for parso==0.8.4\nBest match: parso 0.8.4\nAdding parso 0.8.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nSearching for pycparser==2.21\nBest match: pycparser 2.21\nAdding pycparser 2.21 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.32.0.dev0+f7b522f\nVerifying Orange installation...\n✅ Orange installation successful!\nSuccessfully installed orange using Python 3.7\n",
    "setup_res_stderr": "Using CPython 3.7.9\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 18 packages in 61ms\nPrepared 18 packages in 16ms\nInstalled 18 packages in 46ms\n + cython==0.29.37\n + exceptiongroup==1.2.2\n + importlib-metadata==6.7.0\n + iniconfig==2.0.0\n + numpy==1.17.5\n + packaging==24.0\n + pluggy==1.2.0\n + pyqt5==5.15.10\n + pyqt5-qt5==5.15.16\n + pyqt5-sip==12.13.0\n + pyqtwebengine==5.15.6\n + pyqtwebengine-qt5==5.15.16\n + pytest==7.4.4\n + setuptools==59.8.0\n + tomli==2.0.1\n + typing-extensions==4.7.1\n + wheel==0.42.0\n + zipp==3.15.0\nResolved 55 packages in 256ms\nInstalled 48 packages in 676ms\n + anyio==3.7.1\n + baycomp==1.0.3\n + bottleneck==1.4.0\n + certifi==2024.12.14\n + cffi==1.15.1\n + chardet==5.2.0\n + charset-normalizer==3.4.1\n + cryptography==44.0.0\n + cycler==0.11.0\n + et-xmlfile==1.1.0\n + fonttools==4.38.0\n + h11==0.12.0\n + httpcore==0.13.7\n + httpx==0.19.0\n + idna==3.10\n + importlib-resources==5.12.0\n + jaraco-classes==3.2.3\n + jeepney==0.8.0\n + joblib==1.3.2\n + keyring==24.1.1\n + keyrings-alt==4.2.0\n + kiwisolver==1.4.5\n + matplotlib==3.5.3\n + more-itertools==9.1.0\n + networkx==2.6.3\n + openpyxl==3.1.3\n + opentsne==1.0.1\n + pandas==1.3.5\n + pillow==9.5.0\n + pip==24.0\n + pycparser==2.21\n + pyparsing==3.1.4\n + python-dateutil==2.9.0.post0\n + python-louvain==0.16\n + pytz==2024.2\n + pyyaml==6.0.1\n + requests==2.31.0\n + rfc3986==1.5.0\n + scikit-learn==1.0.2\n + scipy==1.7.3\n + secretstorage==3.3.3\n + serverfiles==0.3.1\n + six==1.17.0\n + sniffio==1.3.1\n + threadpoolctl==3.1.0\n + urllib3==2.0.7\n + xlrd==2.0.1\n + xlsxwriter==3.2.0\nResolved 59 packages in 727ms\nInstalled 38 packages in 755ms\n + anyqt==0.2.0\n + attrs==24.2.0\n + backcall==0.2.0\n + cattrs==23.1.2\n + commonmark==0.9.1\n + debugpy==1.7.0\n + decorator==5.1.1\n + dictdiffer==0.9.0\n + docutils==0.20.1\n + entrypoints==0.4\n + ipykernel==6.16.2\n + ipython==7.34.0\n + ipython-genutils==0.2.0\n + jedi==0.19.2\n + jupyter-client==7.4.9\n + jupyter-core==4.12.0\n + matplotlib-inline==0.1.6\n + nest-asyncio==1.6.0\n + orange-canvas-core==0.1.35\n + orange-widget-base==4.22.0\n + parso==0.8.4\n + pexpect==4.9.0\n + pickleshare==0.7.5\n + platformdirs==4.0.0\n + prompt-toolkit==3.0.48\n + psutil==6.1.1\n + ptyprocess==0.7.0\n + pygments==2.17.2\n + pyqtgraph==0.12.4\n + pyzmq==26.2.0\n + qasync==0.25.0\n + qtconsole==5.4.4\n + qtpy==2.4.2\n + requests-cache==1.1.1\n + tornado==6.2\n + traitlets==5.9.0\n + url-normalize==1.4.3\n + wcwidth==0.2.13\nResolved 2 packages in 4ms\nInstalled 2 packages in 7ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nResolved 19 packages in 142ms\nInstalled 5 packages in 1.05s\n + catboost==1.2.7\n + graphviz==0.20.1\n + plotly==5.18.0\n + tenacity==8.2.3\n + xgboost==1.6.2\nAudited 2 packages in 4ms\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/classification/_tree_scorers.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_2find_threshold_entropy’:\nOrange/classification/_tree_scorers.c:3427:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 3427 |   __pyx_t_7 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_6find_threshold_MSE’:\nOrange/classification/_tree_scorers.c:4883:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 4883 |   __pyx_t_1 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_8find_binarization_MSE’:\nOrange/classification/_tree_scorers.c:5629:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5629 |           for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {\n      |                                           ^\nOrange/classification/_tree_scorers.c:5750:39: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5750 |           __pyx_t_20 = ((__pyx_v_left >= __pyx_v_min_leaf) != 0);\n      |                                       ^~\nOrange/classification/_tree_scorers.c:5756:53: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5756 |           __pyx_t_20 = (((__pyx_v_N - __pyx_v_left) >= __pyx_v_min_leaf) != 0);\n      |                                                     ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_14compute_predictions_csr’:\nOrange/classification/_tree_scorers.c:7217:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7217 |         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_16compute_predictions_csc’:\nOrange/classification/_tree_scorers.c:7874:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7874 |         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c:7934:150: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘unsigned int’ [-Wsign-compare]\n 7934 |               __pyx_t_16 = (((*((__pyx_t_5numpy_int32_t const  *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_15 * __pyx_v_indices.strides[0]) ))) != __pyx_v_i) != 0);\n      |                                                                                                                                                      ^~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_contingency.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/data/_io.c: In function ‘__pyx_pf_6Orange_4data_3_io_sparse_read_float.constprop’:\nOrange/data/_io.c:4120:43: warning: ‘__pyx_v_decs’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4120 |           __pyx_v_value = ((__pyx_v_value * __pyx_v_decs) + (__pyx_v_c & 0xf));\n      |                            ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/data/_io.c:4318:24: warning: ‘__pyx_v_value’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4318 |           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L5_error)\n      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:683:40: warning: ‘__pyx_v_attr_index’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n  683 |   #define PyInt_FromLong               PyLong_FromLong\n      |                                        ^~~~~~~~~~~~~~~\nOrange/data/_io.c:1590:7: note: ‘__pyx_v_attr_index’ was declared here\n 1590 |   int __pyx_v_attr_index;\n      |       ^~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:3183:25: warning: ‘__pyx_v_atomp’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3183 |           __pyx_v_atomp = (__pyx_v_atomp + 1);\n      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_valuecount.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/distance/_distance.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_discretize.c:774:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_relieff.cpp:790:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/projection/_som.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_5update_hex’:\nOrange/projection/_som.c:3863:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3863 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3862:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3862 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_8update_sparse.constprop’:\nOrange/projection/_som.c:4934:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4934 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4933:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4933 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_7get_winners_sparse’:\nOrange/projection/_som.c:4732:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4732 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4307:7: note: ‘__pyx_v_win_y’ was declared here\n 4307 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4721:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4721 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4306:7: note: ‘__pyx_v_win_x’ was declared here\n 4306 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_10update_sparse_hex.constprop’:\nOrange/projection/_som.c:5682:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5682 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:5681:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5681 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_1get_winners’:\nOrange/projection/_som.c:3184:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3184 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2887:7: note: ‘__pyx_v_win_y’ was declared here\n 2887 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3173:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3173 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2886:7: note: ‘__pyx_v_win_x’ was declared here\n 2886 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_3update’:\nOrange/projection/_som.c:3357:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3357 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/classification/_simple_tree.c: In function ‘gain_ratio_c’:\nOrange/classification/_simple_tree.c:63:9: warning: implicit declaration of function ‘qsort_r’; did you mean ‘qsort’? [-Wimplicit-function-declaration]\n   63 |         qsort_r(base, nel, size, compar, thunk)\n      |         ^~~~~~~\nOrange/classification/_simple_tree.c:147:9: note: in expansion of macro ‘QSORT_R_FUNC’\n  147 |         QSORT_R_FUNC(examples, size, sizeof(struct Example), (void*) &compar_attr, compar_examples);\n      |         ^~~~~~~~~~~~\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/setuptools/command/easy_install.py:159: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.\n  EasyInstallDeprecationWarning,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781/.venv/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.\n  setuptools.SetuptoolsDeprecationWarning,\nwarning: no files found matching 'README*' under directory 'Orange'\nwarning: no files found matching 'LICENSE' under directory 'Orange'\nwarning: no files found matching '*.basket' under directory 'Orange/datasets'\nwarning: no files found matching '*.js' under directory 'Orange/widgets'\nwarning: no files found matching '*.css' under directory 'Orange/widgets'\nwarning: no files found matching '*.html' under directory 'Orange/widgets'\nwarning: no files found matching 'COPYING'\n",
    "new_commit_res_code": 1,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781\nplugins: anyio-3.7.1\ncollected 62 items\n\nr2e_tests/test_1.py ....................F.......s..ssssssss.....s....... [ 83%]\n..........                                                               [100%]\n\n=================================== FAILURES ===================================\n_______________ TestPandasCompat.test_table_from_frame_timezones _______________\n\nself = <r2e_tests.test_1.TestPandasCompat testMethod=test_table_from_frame_timezones>\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n>               [np.nan],\n            ],\n        )\nE       AssertionError: \nE       Arrays are not equal\nE       \nE       Mismatched elements: 1 / 3 (33.3%)\nE       Max absolute difference: 2520.\nE       Max relative difference: 3.25902043e-07\nE        x: array([[ 1.513638e+09],\nE              [-7.732382e+09],\nE              [          nan]])\nE        y: array([[ 1.513638e+09],\nE              [-7.732385e+09],\nE              [          nan]])\n\nr2e_tests/test_1.py:362: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date_have_time_in_construct\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_no_date_no_time\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_invalid\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_repr\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_timestamp\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_utc\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_readwrite_timevariable\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_rename\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_repr_value\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_not_orangedf\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_date\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_datetime\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_keep_ids\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_no_datetime\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_time\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frames\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frames_not_orange_dataframe\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frames_same_index\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame_metas\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame_nans\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame_object_dtype\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_time_variable_compatible\nPASSED r2e_tests/test_1.py::TestPandasCompat::testa_table_from_frame_string\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_amend\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_amend_dimension_mismatch\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_basic\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_concat_df\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_concat_table\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_contiguous_x\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_contiguous_y\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_copy\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_merge\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_new_column\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_selection\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_slice\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_to_dfs\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_basic\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_concat_df\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_concat_table\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_copy\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_merge\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_new_column\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_selection\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_slice\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_to_dense\nSKIPPED [1] r2e_tests/test_1.py:453: Convert all Orange demo dataset. It takes about 5s which is way to slow\nSKIPPED [1] r2e_tests/test_1.py:544: Base class\nSKIPPED [1] r2e_tests/test_1.py:634: Base class\nSKIPPED [1] r2e_tests/test_1.py:596: Base class\nSKIPPED [1] r2e_tests/test_1.py:586: Base class\nSKIPPED [1] r2e_tests/test_1.py:654: Base class\nSKIPPED [1] r2e_tests/test_1.py:694: Base class\nSKIPPED [1] r2e_tests/test_1.py:717: Base class\nSKIPPED [1] r2e_tests/test_1.py:572: Base class\nSKIPPED [1] r2e_tests/test_1.py:779: pandas-dev/pandas#39263\nFAILED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_timezones\n=================== 1 failed, 51 passed, 10 skipped in 2.66s ===================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_f7b522fecc65f63a330624ddcaeea8ac64e65781\nplugins: anyio-3.7.1\ncollected 62 items\n\nr2e_tests/test_1.py ..............F.....F.......s.Fssssssss.....s....... [ 83%]\n..........                                                               [100%]\n\n=================================== FAILURES ===================================\n____________________ TestPandasCompat.test_table_from_frame ____________________\n\nself = <r2e_tests.test_1.TestPandasCompat testMethod=test_table_from_frame>\n\n    def test_table_from_frame(self):\n        from Orange.data.pandas_compat import table_from_frame\n    \n        nan = np.nan\n        df = pd.DataFrame([['a', 1, pd.Timestamp('2017-12-19')],\n                           ['b', 0, pd.Timestamp('1724-12-20')],\n                           ['c', 0, pd.Timestamp('1724-12-20')],\n                           [nan, nan, nan]])\n        table = table_from_frame(df)\n        np.testing.assert_equal(table.X,\n                                [[1, pd.Timestamp('2017-12-19').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [0, pd.Timestamp('1724-12-20').timestamp()],\n                                 [nan, nan]])\n        np.testing.assert_equal(\n>           table.metas.tolist(), [[\"a\"], [\"b\"], [\"c\"], [StringVariable.Unknown]]\n        )\nE       AssertionError: \nE       Items are not equal:\nE       item=0\nE       item=3\nE       \nE        ACTUAL: nan\nE        DESIRED: ''\n\nr2e_tests/test_1.py:38: AssertionError\n_______________ TestPandasCompat.test_table_from_frame_timezones _______________\n\nself = <r2e_tests.test_1.TestPandasCompat testMethod=test_table_from_frame_timezones>\n\n    def test_table_from_frame_timezones(self):\n        from Orange.data.pandas_compat import table_from_frame\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(table.domain.variables[0].timezone, timezone.utc)\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00Z\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20Z\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.utc, table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20\").timestamp()],\n                [np.nan],\n            ],\n        )\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.FixedOffset(60), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n                [np.nan],\n            ],\n        )\n    \n        df = pd.DataFrame(\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00\", tz=\"CET\")],\n                [pd.Timestamp(\"1724-12-20 20:20:20\", tz=\"CET\")],\n                [np.nan],\n            ]\n        )\n        table = table_from_frame(df)\n        self.assertEqual(pytz.timezone(\"CET\"), table.domain.variables[0].timezone)\n        np.testing.assert_equal(\n            table.X,\n            [\n                [pd.Timestamp(\"2017-12-19 00:00:00+1\").timestamp()],\n                [pd.Timestamp(\"1724-12-20 20:20:20+1\").timestamp()],\n>               [np.nan],\n            ],\n        )\nE       AssertionError: \nE       Arrays are not equal\nE       \nE       Mismatched elements: 1 / 3 (33.3%)\nE       Max absolute difference: 2520.\nE       Max relative difference: 3.25902043e-07\nE        x: array([[ 1.513638e+09],\nE              [-7.732382e+09],\nE              [          nan]])\nE        y: array([[ 1.513638e+09],\nE              [-7.732385e+09],\nE              [          nan]])\n\nr2e_tests/test_1.py:362: AssertionError\n________________ TestPandasCompat.testa_table_from_frame_string ________________\n\nself = <r2e_tests.test_1.TestPandasCompat testMethod=testa_table_from_frame_string>\n\n    def testa_table_from_frame_string(self):\n        \"\"\"\n        Test if string-like variables are handled correctly and nans are replaced\n        with String.Unknown\n        \"\"\"\n        from Orange.data.pandas_compat import table_from_frame\n    \n        # s1 contains nan and s2 contains pd.Na\n        df = pd.DataFrame(\n            [[\"a\", \"b\"], [\"c\", \"d\"], [\"e\", \"f\"], [5, \"c\"], [np.nan, np.nan]],\n            columns=[\"s1\", \"s2\"],\n        ).astype({\"s1\": \"object\", \"s2\": \"string\"})\n        table = table_from_frame(df)\n        np.testing.assert_array_equal(np.empty((5, 0)), table.X)\n        np.testing.assert_array_equal(\n            np.array(\n                [\n                    [\"a\", \"b\"],\n                    [\"c\", \"d\"],\n                    [\"e\", \"f\"],\n                    [\"5\", \"c\"],\n                    [StringVariable.Unknown, StringVariable.Unknown],\n                ]\n            ),\n>           table.metas,\n        )\nE       AssertionError: \nE       Arrays are not equal\nE       \nE       Mismatched elements: 1 / 1 (100%)\nE        x: array([['a', 'b'],\nE              ['c', 'd'],\nE              ['e', 'f'],...\nE        y: array([['a', 'b'],\nE              ['c', 'd'],\nE              ['e', 'f'],...\n\nr2e_tests/test_1.py:427: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date_have_time_in_construct\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_no_date_no_time\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_invalid\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_repr\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_timestamp\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_utc\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_readwrite_timevariable\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_rename\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_repr_value\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_not_orangedf\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_date\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_datetime\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_keep_ids\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_no_datetime\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_time\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frames\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frames_not_orange_dataframe\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frames_same_index\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame_metas\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame_nans\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_table_to_frame_object_dtype\nPASSED r2e_tests/test_1.py::TestPandasCompat::test_time_variable_compatible\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_amend\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_amend_dimension_mismatch\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_basic\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_concat_df\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_concat_table\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_contiguous_x\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_contiguous_y\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_copy\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_merge\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_new_column\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_selection\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_slice\nPASSED r2e_tests/test_1.py::TestDenseTablePandas::test_to_dfs\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_basic\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_concat_df\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_concat_table\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_copy\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_merge\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_new_column\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_selection\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_slice\nPASSED r2e_tests/test_1.py::TestSparseTablePandas::test_to_dense\nSKIPPED [1] r2e_tests/test_1.py:453: Convert all Orange demo dataset. It takes about 5s which is way to slow\nSKIPPED [1] r2e_tests/test_1.py:544: Base class\nSKIPPED [1] r2e_tests/test_1.py:634: Base class\nSKIPPED [1] r2e_tests/test_1.py:596: Base class\nSKIPPED [1] r2e_tests/test_1.py:586: Base class\nSKIPPED [1] r2e_tests/test_1.py:654: Base class\nSKIPPED [1] r2e_tests/test_1.py:694: Base class\nSKIPPED [1] r2e_tests/test_1.py:717: Base class\nSKIPPED [1] r2e_tests/test_1.py:572: Base class\nSKIPPED [1] r2e_tests/test_1.py:779: pandas-dev/pandas#39263\nFAILED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame - Asserti...\nFAILED r2e_tests/test_1.py::TestPandasCompat::test_table_from_frame_timezones\nFAILED r2e_tests/test_1.py::TestPandasCompat::testa_table_from_frame_string\n=================== 3 failed, 49 passed, 10 skipped in 2.35s ===================\n",
    "old_commit_res_stderr": ""
}
Orange/data/pandas_compat.py Orange/data/tests/test_pandas.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
### Title: `table_from_frame` Fails to Replace NaN with `StringVariable.Unknown` for String Variables

#### Description
When converting a pandas DataFrame to an Orange Table using the `table_from_frame` function, NaN values in string columns are not being replaced with `StringVariable.Unknown`. Instead, these NaN values persist in the `metas`, leading to assertion failures and inconsistent data representation.

**Example Buggy Code:**
```python
import pandas as pd
from Orange.data import table_from_frame, StringVariable

# Create a DataFrame with NaN values in string columns
df = pd.DataFrame([
    ['a', 'b'],
    ['c', 'd'],
    ['e', 'f'],
    [5, 'c'],
    [None, None]  # NaN values
], columns=['s1', 's2']).astype({'s1': 'object', 's2': 'string'})

# Convert DataFrame to Orange Table
table = table_from_frame(df)

# Inspect metas to check for StringVariable.Unknown
print(table.metas)
```

**Expected Behavior:**
All NaN values in string columns (`s1` and `s2`) should be replaced with `StringVariable.Unknown` within the `metas` of the resulting Orange Table. This ensures consistency and prevents issues in downstream processing and testing.

**Actual Behavior:**
NaN values remain in the `metas` instead of being replaced with `StringVariable.Unknown`. This causes tests that expect `StringVariable.Unknown` to fail, as seen in the following assertion errors:

- `TestPandasCompat.test_table_from_frame` expects `[['a'], ['b'], ['c'], [StringVariable.Unknown]]` but receives `nan` instead.
- `TestPandasCompat.testa_table_from_frame_string` expects `[['a', 'b'], ['c', 'd'], ['e', 'f'], ['5', 'c'], [StringVariable.Unknown, StringVariable.Unknown]]` but finds NaN values.

#### Steps to Reproduce
1. Create a pandas DataFrame with NaN values in string-type columns.
2. Use the `table_from_frame` function to convert the DataFrame to an Orange Table.
3. Inspect the `metas` attribute of the resulting Table to observe the presence of NaN values instead of `StringVariable.Unknown`.

#### Impact
This issue leads to inconsistent data handling within Orange Tables, causing failed assertions in tests and potential data integrity problems in applications relying on these Tables.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/data/pandas_compat.py
"""Pandas DataFrame↔Table conversion helpers"""
from unittest.mock import patch

import numpy as np
from pandas.core.dtypes.common import is_string_dtype
from scipy import sparse as sp
from scipy.sparse import csr_matrix
import pandas as pd
from pandas.core.arrays import SparseArray
from pandas.core.arrays.sparse.dtype import SparseDtype
from pandas.api.types import (
    is_categorical_dtype, is_object_dtype,
    is_datetime64_any_dtype, is_numeric_dtype, is_integer_dtype
)

from Orange.data import (
    Table, Domain, DiscreteVariable, StringVariable, TimeVariable,
    ContinuousVariable,
)
from Orange.data.table import Role

__all__ = ['table_from_frame', 'table_to_frame']


class OrangeDataFrame(pd.DataFrame):
    _metadata = ["orange_variables", "orange_weights",
                 "orange_attributes", "orange_role"]

    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 __patch_constructor(self, method):
        def new_method(*args, **kwargs):
            with patch(
                    'pandas.DataFrame',
                    OrangeDataFrame
            ):
                df = method(*args, **kwargs)
            df.__finalize__(self)
            return df

        return new_method

    @property
    def _constructor(self):
        return OrangeDataFrame

    def to_orange_table(self):
        return table_from_frame(self)

    def __finalize__(self, other, method=None, **_):
        """
        propagate metadata from other to self

        Parameters
        ----------
        other : the object from which to get the attributes that we are going
            to propagate
        method : optional, a passed method name ; possibly to take different
            types of propagation actions based on this

        """
        if method == 'concat':
            objs = other.objs
        elif method == 'merge':
            objs = other.left, other.right
        else:
            objs = [other]

        orange_role = getattr(self, 'orange_role', None)
        dicts = {dname: getattr(self, dname, {})
                 for dname in ('orange_variables',
                               'orange_weights',
                               'orange_attributes')}
        for obj in objs:
            other_role = getattr(obj, 'orange_role', None)
            if other_role is not None:
                orange_role = other_role

            for dname, dict_ in dicts.items():
                other_dict = getattr(obj, dname, {})
                dict_.update(other_dict)

        object.__setattr__(self, 'orange_role', orange_role)
        for dname, dict_ in dicts.items():
            object.__setattr__(self, dname, dict_)

        return self

    pd.DataFrame.__finalize__ = __finalize__


def _reset_index(df: pd.DataFrame) -> pd.DataFrame:
    """If df index is not a simple RangeIndex (or similar), include it into a table"""
    if (
        # not range-like index - test first to skip slow startswith(_o) check
        not (
            df.index.is_integer()
            and (df.index.is_monotonic_increasing or df.index.is_monotonic_decreasing)
        )
        # check that it does not contain Orange index
        and (
            # startswith is slow (for long dfs) - firs check if col has strings
            isinstance(df.index, pd.MultiIndex)
            or not is_string_dtype(df.index)
            or not any(str(i).startswith("_o") for i in df.index)
        )
    ):
        df = df.reset_index()
    return df


def _is_discrete(s, force_nominal):
    return (is_categorical_dtype(s) or
            is_object_dtype(s) and (force_nominal or
                                    s.nunique() < s.size ** .666))


def _is_datetime(s):
    if is_datetime64_any_dtype(s):
        return True
    try:
        if is_object_dtype(s):
            # pd.to_datetime would sucessfuly parse column of numbers to datetime
            # but for column of object dtype with numbers we want to be either
            # discret or string - following code try to parse column to numeric
            # if connversion to numeric is sucessful return False
            try:
                pd.to_numeric(s)
                return False
            except (ValueError, TypeError):
                pass

            # utc=True - to allow different timezones in a series object
            pd.to_datetime(s, infer_datetime_format=True, utc=True)
            return True
    except Exception:  # pylint: disable=broad-except
        pass
    return False


def _convert_datetime(series, var):
    def col_type(dt):
        """Test if is date, time or datetime"""
        dt_nonnat = dt[~pd.isnull(dt)]  # nat == nat is False
        if (dt_nonnat.dt.floor("d") == dt_nonnat).all():
            # all times are 00:00:00.0 - pure date
            return 1, 0
        elif (dt_nonnat.dt.date == pd.Timestamp("now").date()).all():
            # all dates are today's date - pure time
            return 0, 1  # pure time
        else:
            # else datetime
            return 1, 1

    try:
        dt = pd.to_datetime(series)
    except ValueError:
        # series with type object and different timezones will raise a
        # ValueError - normalizing to utc
        dt = pd.to_datetime(series, utc=True)

    # set variable type to date, time or datetime
    var.have_date, var.have_time = col_type(dt)

    if dt.dt.tz is not None:
        # set timezone if available and convert to utc
        var.timezone = dt.dt.tz
        dt = dt.dt.tz_convert("UTC")

    if var.have_time and not var.have_date:
        # if time only measure seconds from midnight - equal to setting date
        # to unix epoch
        return (
            (dt.dt.tz_localize(None) - pd.Timestamp("now").normalize())
            / pd.Timedelta("1s")
        ).values

    return (
        (dt.dt.tz_localize(None) - pd.Timestamp("1970-01-01")) / pd.Timedelta("1s")
    ).values


def to_categorical(s, _):
    x = s.astype("category").cat.codes
    # it is same than x.replace(-1, np.nan), but much faster
    x = x.where(x != -1, np.nan)
    return np.asarray(x)


def vars_from_df(df, role=None, force_nominal=False):
    if role is None and hasattr(df, 'orange_role'):
        role = df.orange_role
    df = _reset_index(df)

    cols = [], [], []
    exprs = [], [], []
    vars_ = [], [], []

    for column in df.columns:
        s = df[column]
        _role = Role.Attribute if role is None else role
        if hasattr(df, 'orange_variables') and column in df.orange_variables:
            original_var = df.orange_variables[column]
            var = original_var.copy(compute_value=None)
            expr = None
        elif _is_datetime(s):
            var = TimeVariable(str(column))
            expr = _convert_datetime
        elif _is_discrete(s, force_nominal):
            discrete = s.astype("category").cat
            var = DiscreteVariable(
                str(column), discrete.categories.astype(str).tolist()
            )
            expr = to_categorical
        elif is_numeric_dtype(s):
            var = ContinuousVariable(
                # set number of decimals to 0 if int else keeps default behaviour
                str(column), number_of_decimals=(0 if is_integer_dtype(s) else None)
            )
            expr = None
        else:
            if role is not None and role != Role.Meta:
                raise ValueError("String variable must be in metas.")
            _role = Role.Meta
            var = StringVariable(str(column))
            expr = lambda s, _: np.asarray(s, dtype=object)

        cols[_role].append(column)
        exprs[_role].append(expr)
        vars_[_role].append(var)

    xym = []
    for a_vars, a_cols, a_expr in zip(vars_, cols, exprs):
        if not a_cols:
            arr = None if a_cols != cols[0] else np.empty((df.shape[0], 0))
        elif not any(a_expr):
            # if all c in columns table will share memory with dataframe
            a_df = df if all(c in a_cols for c in df.columns) else df[a_cols]
            if all(isinstance(a, SparseDtype) for a in a_df.dtypes):
                arr = csr_matrix(a_df.sparse.to_coo())
            else:
                arr = np.asarray(a_df)
        else:
            # we'll have to copy the table to resolve any expressions
            arr = np.array(
                [
                    expr(df[col], var) if expr else np.asarray(df[col])
                    for var, col, expr in zip(a_vars, a_cols, a_expr)
                ]
            ).T
        xym.append(arr)

    # Let the tables share memory with pandas frame
    if xym[1] is not None and xym[1].ndim == 2 and xym[1].shape[1] == 1:
        xym[1] = xym[1][:, 0]

    return xym, Domain(*vars_)


def table_from_frame(df, *, force_nominal=False):
    XYM, domain = vars_from_df(df, force_nominal=force_nominal)

    if hasattr(df, 'orange_weights') and hasattr(df, 'orange_attributes'):
        W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]
        if len(W) != len(df.index):
            W = None
        attributes = df.orange_attributes
        if isinstance(df.index, pd.MultiIndex) or not is_string_dtype(df.index):
            # we can skip checking for Orange indices when MultiIndex an when
            # not string dtype and so speedup the conversion
            ids = None
        else:
            ids = [
                int(i[2:])
                if str(i).startswith("_o") and i[2:].isdigit()
                else Table.new_id()
                for i in df.index
            ]
    else:
        W = None
        attributes = None
        ids = None

    return Table.from_numpy(
        domain,
        *XYM,
        W=W,
        attributes=attributes,
        ids=ids
    )


def table_from_frames(xdf, ydf, mdf):
    if not (xdf.index.equals(ydf.index) and xdf.index.equals(mdf.index)):
        raise ValueError(
            "Indexes not equal. Make sure that all three dataframes have equal index"
        )

    # drop index from x and y - it makes sure that index if not range will be
    # placed in metas
    xdf = xdf.reset_index(drop=True)
    ydf = ydf.reset_index(drop=True)
    dfs = xdf, ydf, mdf

    if not all(df.shape[0] == xdf.shape[0] for df in dfs):
        raise ValueError(f"Leading dimension mismatch "
                         f"(not {xdf.shape[0]} == {ydf.shape[0]} == {mdf.shape[0]})")

    xXYM, xDomain = vars_from_df(xdf, role=Role.Attribute)
    yXYM, yDomain = vars_from_df(ydf, role=Role.ClassAttribute)
    mXYM, mDomain = vars_from_df(mdf, role=Role.Meta)

    XYM = (xXYM[0], yXYM[1], mXYM[2])
    domain = Domain(xDomain.attributes, yDomain.class_vars, mDomain.metas)

    ids = [
        int(idx[2:])
        if str(idx).startswith("_o") and idx[2:].isdigit()
        else Table.new_id()
        for idx in mdf.index
    ]

    attributes = {}
    W = None
    for df in dfs:
        if isinstance(df, OrangeDataFrame):
            W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]
            if len(W) != len(df.index):
                W = None
            attributes.update(df.orange_attributes)
        else:
            W = None

    return Table.from_numpy(
        domain,
        *XYM,
        W=W,
        attributes=attributes,
        ids=ids
    )


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_frames(table):
    xdf = OrangeDataFrame(table, Role.Attribute)
    ydf = OrangeDataFrame(table, Role.ClassAttribute)
    mdf = OrangeDataFrame(table, Role.Meta)

    return xdf, ydf, mdf


def amend_table_with_frame(table, df, role):
    arr = Role.get_arr(role, table)
    if arr.shape[0] != df.shape[0]:
        raise ValueError(f"Leading dimension mismatch "
                         f"(not {arr.shape[0]} == {df.shape[0]})")

    XYM, domain = vars_from_df(df, role=role)

    if role == Role.Attribute:
        table.domain = Domain(domain.attributes,
                              table.domain.class_vars,
                              table.domain.metas)
        table.X = XYM[0]
    elif role == Role.ClassAttribute:
        table.domain = Domain(table.domain.attributes,
                              domain.class_vars,
                              table.domain.metas)
        table.Y = XYM[1]
    else:  # if role == Role.Meta:
        table.domain = Domain(table.domain.attributes,
                              table.domain.class_vars,
                              domain.metas)
        table.metas = XYM[2]

    if isinstance(df, OrangeDataFrame):
        table.attributes.update(df.orange_attributes)

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
### Title: `table_from_frame` Fails to Replace NaN with `StringVariable.Unknown` for String Variables

#### Description
When converting a pandas DataFrame to an Orange Table using the `table_from_frame` function, NaN values in string columns are not being replaced with `StringVariable.Unknown`. Instead, these NaN values persist in the `metas`, leading to assertion failures and inconsistent data representation.

**Example Buggy Code:**
```python
import pandas as pd
from Orange.data import table_from_frame, StringVariable

# Create a DataFrame with NaN values in string columns
df = pd.DataFrame([
    ['a', 'b'],
    ['c', 'd'],
    ['e', 'f'],
    [5, 'c'],
    [None, None]  # NaN values
], columns=['s1', 's2']).astype({'s1': 'object', 's2': 'string'})

# Convert DataFrame to Orange Table
table = table_from_frame(df)

# Inspect metas to check for StringVariable.Unknown
print(table.metas)
```

**Expected Behavior:**
All NaN values in string columns (`s1` and `s2`) should be replaced with `StringVariable.Unknown` within the `metas` of the resulting Orange Table. This ensures consistency and prevents issues in downstream processing and testing.

**Actual Behavior:**
NaN values remain in the `metas` instead of being replaced with `StringVariable.Unknown`. This causes tests that expect `StringVariable.Unknown` to fail, as seen in the following assertion errors:

- `TestPandasCompat.test_table_from_frame` expects `[['a'], ['b'], ['c'], [StringVariable.Unknown]]` but receives `nan` instead.
- `TestPandasCompat.testa_table_from_frame_string` expects `[['a', 'b'], ['c', 'd'], ['e', 'f'], ['5', 'c'], [StringVariable.Unknown, StringVariable.Unknown]]` but finds NaN values.

#### Steps to Reproduce
1. Create a pandas DataFrame with NaN values in string-type columns.
2. Use the `table_from_frame` function to convert the DataFrame to an Orange Table.
3. Inspect the `metas` attribute of the resulting Table to observe the presence of NaN values instead of `StringVariable.Unknown`.

#### Impact
This issue leads to inconsistent data handling within Orange Tables, causing failed assertions in tests and potential data integrity problems in applications relying on these Tables.

[/ISSUE]
{
    "TestTimeVariable.test_copy_copies_attributes": "PASSED",
    "TestTimeVariable.test_dont_make_anonymous_variables": "PASSED",
    "TestTimeVariable.test_dont_pickle_anonymous_variables": "PASSED",
    "TestTimeVariable.test_have_date": "PASSED",
    "TestTimeVariable.test_have_date_have_time_in_construct": "PASSED",
    "TestTimeVariable.test_no_date_no_time": "PASSED",
    "TestTimeVariable.test_parse_invalid": "PASSED",
    "TestTimeVariable.test_parse_repr": "PASSED",
    "TestTimeVariable.test_parse_timestamp": "PASSED",
    "TestTimeVariable.test_parse_utc": "PASSED",
    "TestTimeVariable.test_readwrite_timevariable": "PASSED",
    "TestTimeVariable.test_rename": "PASSED",
    "TestTimeVariable.test_repr_value": "PASSED",
    "TestPandasCompat.test_not_orangedf": "PASSED",
    "TestPandasCompat.test_table_from_frame": "PASSED",
    "TestPandasCompat.test_table_from_frame_date": "PASSED",
    "TestPandasCompat.test_table_from_frame_datetime": "PASSED",
    "TestPandasCompat.test_table_from_frame_keep_ids": "PASSED",
    "TestPandasCompat.test_table_from_frame_no_datetime": "PASSED",
    "TestPandasCompat.test_table_from_frame_time": "PASSED",
    "TestPandasCompat.test_table_from_frames": "PASSED",
    "TestPandasCompat.test_table_from_frames_not_orange_dataframe": "PASSED",
    "TestPandasCompat.test_table_from_frames_same_index": "PASSED",
    "TestPandasCompat.test_table_to_frame": "PASSED",
    "TestPandasCompat.test_table_to_frame_metas": "PASSED",
    "TestPandasCompat.test_table_to_frame_nans": "PASSED",
    "TestPandasCompat.test_table_to_frame_object_dtype": "PASSED",
    "TestPandasCompat.test_time_variable_compatible": "PASSED",
    "TestPandasCompat.testa_table_from_frame_string": "PASSED",
    "TestDenseTablePandas.test_amend": "PASSED",
    "TestDenseTablePandas.test_amend_dimension_mismatch": "PASSED",
    "TestDenseTablePandas.test_basic": "PASSED",
    "TestDenseTablePandas.test_concat_df": "PASSED",
    "TestDenseTablePandas.test_concat_table": "PASSED",
    "TestDenseTablePandas.test_contiguous_x": "PASSED",
    "TestDenseTablePandas.test_contiguous_y": "PASSED",
    "TestDenseTablePandas.test_copy": "PASSED",
    "TestDenseTablePandas.test_merge": "PASSED",
    "TestDenseTablePandas.test_new_column": "PASSED",
    "TestDenseTablePandas.test_selection": "PASSED",
    "TestDenseTablePandas.test_slice": "PASSED",
    "TestDenseTablePandas.test_to_dfs": "PASSED",
    "TestSparseTablePandas.test_basic": "PASSED",
    "TestSparseTablePandas.test_concat_df": "PASSED",
    "TestSparseTablePandas.test_concat_table": "PASSED",
    "TestSparseTablePandas.test_copy": "PASSED",
    "TestSparseTablePandas.test_merge": "PASSED",
    "TestSparseTablePandas.test_new_column": "PASSED",
    "TestSparseTablePandas.test_selection": "PASSED",
    "TestSparseTablePandas.test_slice": "PASSED",
    "TestSparseTablePandas.test_to_dense": "PASSED",
    "TestPandasCompat.test_table_from_frame_timezones": "FAILED"
}
diff --git a/Orange/data/pandas_compat.py b/Orange/data/pandas_compat.py
index 788c06394..fb80b4954 100644
--- a/Orange/data/pandas_compat.py
+++ b/Orange/data/pandas_compat.py
@@ -280,7 +280,12 @@ def vars_from_df(df, role=None, force_nominal=False):
                 raise ValueError("String variable must be in metas.")
             _role = Role.Meta
             var = StringVariable(str(column))
-            expr = lambda s, _: np.asarray(s, dtype=object)
+            expr = lambda s, _: np.asarray(
+                # to object so that fillna can replace with nans if Unknown in nan
+                # replace nan with object Unknown assure that all values are string
+                s.astype(object).fillna(StringVariable.Unknown).astype(str),
+                dtype=object
+            )
 
         cols[_role].append(column)
         exprs[_role].append(expr)

{"Orange/data/pandas_compat.py": "\"\"\"Pandas DataFrame\u2194Table conversion helpers\"\"\"\nfrom unittest.mock import patch\n\nimport numpy as np\nfrom pandas.core.dtypes.common import is_string_dtype\nfrom scipy import sparse as sp\nfrom scipy.sparse import csr_matrix\nimport pandas as pd\nfrom pandas.core.arrays import SparseArray\nfrom pandas.core.arrays.sparse.dtype import SparseDtype\nfrom pandas.api.types import (\n    is_categorical_dtype, is_object_dtype,\n    is_datetime64_any_dtype, is_numeric_dtype, is_integer_dtype\n)\n\nfrom Orange.data import (\n    Table, Domain, DiscreteVariable, StringVariable, TimeVariable,\n    ContinuousVariable,\n)\nfrom Orange.data.table import Role\n\n__all__ = ['table_from_frame', 'table_to_frame']\n\n\nclass OrangeDataFrame(pd.DataFrame):\n    _metadata = [\"orange_variables\", \"orange_weights\",\n                 \"orange_attributes\", \"orange_role\"]\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n        A pandas DataFrame wrapper for one of Table's numpy arrays:\n            - sets index values corresponding to Orange's global row indices\n              e.g. ['_o1', '_o2'] (allows Orange to handle selection)\n            - remembers the array's role in the Table (attribute, class var, meta)\n            - keeps the Variable objects, and uses them in back-to-table conversion,\n              should a column name match a variable's name\n            - stores weight values (legacy)\n\n        Parameters\n        ----------\n        table : Table\n        orange_role : Role, (default=Role.Attribute)\n            When converting back to an orange table, the DataFrame will\n            convert to the right role (attrs, class vars, or metas)\n        \"\"\"\n        if len(args) <= 0 or not isinstance(args[0], Table):\n            super().__init__(*args, **kwargs)\n            return\n        table = args[0]\n        if 'orange_role' in kwargs:\n            role = kwargs.pop('orange_role')\n        elif len(args) >= 2:\n            role = args[1]\n        else:\n            role = Role.Attribute\n\n        if role == Role.Attribute:\n            data = table.X\n            vars_ = table.domain.attributes\n        elif role == Role.ClassAttribute:\n            data = table.Y\n            vars_ = table.domain.class_vars\n        else:  # if role == Role.Meta:\n            data = table.metas\n            vars_ = table.domain.metas\n\n        index = ['_o' + str(id_) for id_ in table.ids]\n        varsdict = {var._name: var for var in vars_}\n        columns = varsdict.keys()\n\n        if sp.issparse(data):\n            data = data.asformat('csc')\n            sparrays = [SparseArray.from_spmatrix(data[:, i]) for i in range(data.shape[1])]\n            data = dict(enumerate(sparrays))\n            super().__init__(data, index=index, **kwargs)\n            self.columns = columns\n            # a hack to keep Orange df _metadata in sparse->dense conversion\n            self.sparse.to_dense = self.__patch_constructor(self.sparse.to_dense)\n        else:\n            super().__init__(data=data, index=index, columns=columns, **kwargs)\n\n        self.orange_role = role\n        self.orange_variables = varsdict\n        self.orange_weights = (dict(zip(index, table.W))\n                               if table.W.size > 0 else {})\n        self.orange_attributes = table.attributes\n\n    def __patch_constructor(self, method):\n        def new_method(*args, **kwargs):\n            with patch(\n                    'pandas.DataFrame',\n                    OrangeDataFrame\n            ):\n                df = method(*args, **kwargs)\n            df.__finalize__(self)\n            return df\n\n        return new_method\n\n    @property\n    def _constructor(self):\n        return OrangeDataFrame\n\n    def to_orange_table(self):\n        return table_from_frame(self)\n\n    def __finalize__(self, other, method=None, **_):\n        \"\"\"\n        propagate metadata from other to self\n\n        Parameters\n        ----------\n        other : the object from which to get the attributes that we are going\n            to propagate\n        method : optional, a passed method name ; possibly to take different\n            types of propagation actions based on this\n\n        \"\"\"\n        if method == 'concat':\n            objs = other.objs\n        elif method == 'merge':\n            objs = other.left, other.right\n        else:\n            objs = [other]\n\n        orange_role = getattr(self, 'orange_role', None)\n        dicts = {dname: getattr(self, dname, {})\n                 for dname in ('orange_variables',\n                               'orange_weights',\n                               'orange_attributes')}\n        for obj in objs:\n            other_role = getattr(obj, 'orange_role', None)\n            if other_role is not None:\n                orange_role = other_role\n\n            for dname, dict_ in dicts.items():\n                other_dict = getattr(obj, dname, {})\n                dict_.update(other_dict)\n\n        object.__setattr__(self, 'orange_role', orange_role)\n        for dname, dict_ in dicts.items():\n            object.__setattr__(self, dname, dict_)\n\n        return self\n\n    pd.DataFrame.__finalize__ = __finalize__\n\n\ndef _reset_index(df: pd.DataFrame) -> pd.DataFrame:\n    \"\"\"If df index is not a simple RangeIndex (or similar), include it into a table\"\"\"\n    if (\n        # not range-like index - test first to skip slow startswith(_o) check\n        not (\n            df.index.is_integer()\n            and (df.index.is_monotonic_increasing or df.index.is_monotonic_decreasing)\n        )\n        # check that it does not contain Orange index\n        and (\n            # startswith is slow (for long dfs) - firs check if col has strings\n            isinstance(df.index, pd.MultiIndex)\n            or not is_string_dtype(df.index)\n            or not any(str(i).startswith(\"_o\") for i in df.index)\n        )\n    ):\n        df = df.reset_index()\n    return df\n\n\ndef _is_discrete(s, force_nominal):\n    return (is_categorical_dtype(s) or\n            is_object_dtype(s) and (force_nominal or\n                                    s.nunique() < s.size ** .666))\n\n\ndef _is_datetime(s):\n    if is_datetime64_any_dtype(s):\n        return True\n    try:\n        if is_object_dtype(s):\n            # pd.to_datetime would sucessfuly parse column of numbers to datetime\n            # but for column of object dtype with numbers we want to be either\n            # discret or string - following code try to parse column to numeric\n            # if connversion to numeric is sucessful return False\n            try:\n                pd.to_numeric(s)\n                return False\n            except (ValueError, TypeError):\n                pass\n\n            # utc=True - to allow different timezones in a series object\n            pd.to_datetime(s, infer_datetime_format=True, utc=True)\n            return True\n    except Exception:  # pylint: disable=broad-except\n        pass\n    return False\n\n\ndef _convert_datetime(series, var):\n    def col_type(dt):\n        \"\"\"Test if is date, time or datetime\"\"\"\n        dt_nonnat = dt[~pd.isnull(dt)]  # nat == nat is False\n        if (dt_nonnat.dt.floor(\"d\") == dt_nonnat).all():\n            # all times are 00:00:00.0 - pure date\n            return 1, 0\n        elif (dt_nonnat.dt.date == pd.Timestamp(\"now\").date()).all():\n            # all dates are today's date - pure time\n            return 0, 1  # pure time\n        else:\n            # else datetime\n            return 1, 1\n\n    try:\n        dt = pd.to_datetime(series)\n    except ValueError:\n        # series with type object and different timezones will raise a\n        # ValueError - normalizing to utc\n        dt = pd.to_datetime(series, utc=True)\n\n    # set variable type to date, time or datetime\n    var.have_date, var.have_time = col_type(dt)\n\n    if dt.dt.tz is not None:\n        # set timezone if available and convert to utc\n        var.timezone = dt.dt.tz\n        dt = dt.dt.tz_convert(\"UTC\")\n\n    if var.have_time and not var.have_date:\n        # if time only measure seconds from midnight - equal to setting date\n        # to unix epoch\n        return (\n            (dt.dt.tz_localize(None) - pd.Timestamp(\"now\").normalize())\n            / pd.Timedelta(\"1s\")\n        ).values\n\n    return (\n        (dt.dt.tz_localize(None) - pd.Timestamp(\"1970-01-01\")) / pd.Timedelta(\"1s\")\n    ).values\n\n\ndef to_categorical(s, _):\n    x = s.astype(\"category\").cat.codes\n    # it is same than x.replace(-1, np.nan), but much faster\n    x = x.where(x != -1, np.nan)\n    return np.asarray(x)\n\n\ndef vars_from_df(df, role=None, force_nominal=False):\n    if role is None and hasattr(df, 'orange_role'):\n        role = df.orange_role\n    df = _reset_index(df)\n\n    cols = [], [], []\n    exprs = [], [], []\n    vars_ = [], [], []\n\n    for column in df.columns:\n        s = df[column]\n        _role = Role.Attribute if role is None else role\n        if hasattr(df, 'orange_variables') and column in df.orange_variables:\n            original_var = df.orange_variables[column]\n            var = original_var.copy(compute_value=None)\n            expr = None\n        elif _is_datetime(s):\n            var = TimeVariable(str(column))\n            expr = _convert_datetime\n        elif _is_discrete(s, force_nominal):\n            discrete = s.astype(\"category\").cat\n            var = DiscreteVariable(\n                str(column), discrete.categories.astype(str).tolist()\n            )\n            expr = to_categorical\n        elif is_numeric_dtype(s):\n            var = ContinuousVariable(\n                # set number of decimals to 0 if int else keeps default behaviour\n                str(column), number_of_decimals=(0 if is_integer_dtype(s) else None)\n            )\n            expr = None\n        else:\n            if role is not None and role != Role.Meta:\n                raise ValueError(\"String variable must be in metas.\")\n            _role = Role.Meta\n            var = StringVariable(str(column))\n            expr = lambda s, _: np.asarray(s, dtype=object)\n\n        cols[_role].append(column)\n        exprs[_role].append(expr)\n        vars_[_role].append(var)\n\n    xym = []\n    for a_vars, a_cols, a_expr in zip(vars_, cols, exprs):\n        if not a_cols:\n            arr = None if a_cols != cols[0] else np.empty((df.shape[0], 0))\n        elif not any(a_expr):\n            # if all c in columns table will share memory with dataframe\n            a_df = df if all(c in a_cols for c in df.columns) else df[a_cols]\n            if all(isinstance(a, SparseDtype) for a in a_df.dtypes):\n                arr = csr_matrix(a_df.sparse.to_coo())\n            else:\n                arr = np.asarray(a_df)\n        else:\n            # we'll have to copy the table to resolve any expressions\n            arr = np.array(\n                [\n                    expr(df[col], var) if expr else np.asarray(df[col])\n                    for var, col, expr in zip(a_vars, a_cols, a_expr)\n                ]\n            ).T\n        xym.append(arr)\n\n    # Let the tables share memory with pandas frame\n    if xym[1] is not None and xym[1].ndim == 2 and xym[1].shape[1] == 1:\n        xym[1] = xym[1][:, 0]\n\n    return xym, Domain(*vars_)\n\n\ndef table_from_frame(df, *, force_nominal=False):\n    XYM, domain = vars_from_df(df, force_nominal=force_nominal)\n\n    if hasattr(df, 'orange_weights') and hasattr(df, 'orange_attributes'):\n        W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]\n        if len(W) != len(df.index):\n            W = None\n        attributes = df.orange_attributes\n        if isinstance(df.index, pd.MultiIndex) or not is_string_dtype(df.index):\n            # we can skip checking for Orange indices when MultiIndex an when\n            # not string dtype and so speedup the conversion\n            ids = None\n        else:\n            ids = [\n                int(i[2:])\n                if str(i).startswith(\"_o\") and i[2:].isdigit()\n                else Table.new_id()\n                for i in df.index\n            ]\n    else:\n        W = None\n        attributes = None\n        ids = None\n\n    return Table.from_numpy(\n        domain,\n        *XYM,\n        W=W,\n        attributes=attributes,\n        ids=ids\n    )\n\n\ndef table_from_frames(xdf, ydf, mdf):\n    if not (xdf.index.equals(ydf.index) and xdf.index.equals(mdf.index)):\n        raise ValueError(\n            \"Indexes not equal. Make sure that all three dataframes have equal index\"\n        )\n\n    # drop index from x and y - it makes sure that index if not range will be\n    # placed in metas\n    xdf = xdf.reset_index(drop=True)\n    ydf = ydf.reset_index(drop=True)\n    dfs = xdf, ydf, mdf\n\n    if not all(df.shape[0] == xdf.shape[0] for df in dfs):\n        raise ValueError(f\"Leading dimension mismatch \"\n                         f\"(not {xdf.shape[0]} == {ydf.shape[0]} == {mdf.shape[0]})\")\n\n    xXYM, xDomain = vars_from_df(xdf, role=Role.Attribute)\n    yXYM, yDomain = vars_from_df(ydf, role=Role.ClassAttribute)\n    mXYM, mDomain = vars_from_df(mdf, role=Role.Meta)\n\n    XYM = (xXYM[0], yXYM[1], mXYM[2])\n    domain = Domain(xDomain.attributes, yDomain.class_vars, mDomain.metas)\n\n    ids = [\n        int(idx[2:])\n        if str(idx).startswith(\"_o\") and idx[2:].isdigit()\n        else Table.new_id()\n        for idx in mdf.index\n    ]\n\n    attributes = {}\n    W = None\n    for df in dfs:\n        if isinstance(df, OrangeDataFrame):\n            W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]\n            if len(W) != len(df.index):\n                W = None\n            attributes.update(df.orange_attributes)\n        else:\n            W = None\n\n    return Table.from_numpy(\n        domain,\n        *XYM,\n        W=W,\n        attributes=attributes,\n        ids=ids\n    )\n\n\ndef table_to_frame(tab, include_metas=False):\n    \"\"\"\n    Convert Orange.data.Table to pandas.DataFrame\n\n    Parameters\n    ----------\n    tab : Table\n\n    include_metas : bool, (default=False)\n        Include table metas into dataframe.\n\n    Returns\n    -------\n    pandas.DataFrame\n    \"\"\"\n\n    def _column_to_series(col, vals):\n        result = ()\n        if col.is_discrete:\n            codes = pd.Series(vals).fillna(-1).astype(int)\n            result = (col.name, pd.Categorical.from_codes(\n                codes=codes, categories=col.values, ordered=True\n            ))\n        elif col.is_time:\n            result = (col.name, pd.to_datetime(vals, unit='s').to_series().reset_index()[0])\n        elif col.is_continuous:\n            dt = float\n            # np.nan are not compatible with int column\n            # using pd.isnull since np.isnan fails on array with dtype object\n            # which can happen when metas contain column with strings\n            if col.number_of_decimals == 0 and not np.any(pd.isnull(vals)):\n                dt = int\n            result = (col.name, pd.Series(vals).astype(dt))\n        elif col.is_string:\n            result = (col.name, pd.Series(vals))\n        return result\n\n    def _columns_to_series(cols, vals):\n        return [_column_to_series(col, vals[:, i]) for i, col in enumerate(cols)]\n\n    x, y, metas = [], [], []\n    domain = tab.domain\n    if domain.attributes:\n        x = _columns_to_series(domain.attributes, tab.X)\n    if domain.class_vars:\n        y_values = tab.Y.reshape(tab.Y.shape[0], len(domain.class_vars))\n        y = _columns_to_series(domain.class_vars, y_values)\n    if domain.metas:\n        metas = _columns_to_series(domain.metas, tab.metas)\n    all_series = dict(x + y + metas)\n    all_vars = tab.domain.variables\n    if include_metas:\n        all_vars += tab.domain.metas\n    original_column_order = [var.name for var in all_vars]\n    unsorted_columns_df = pd.DataFrame(all_series)\n    return unsorted_columns_df[original_column_order]\n\n\ndef table_to_frames(table):\n    xdf = OrangeDataFrame(table, Role.Attribute)\n    ydf = OrangeDataFrame(table, Role.ClassAttribute)\n    mdf = OrangeDataFrame(table, Role.Meta)\n\n    return xdf, ydf, mdf\n\n\ndef amend_table_with_frame(table, df, role):\n    arr = Role.get_arr(role, table)\n    if arr.shape[0] != df.shape[0]:\n        raise ValueError(f\"Leading dimension mismatch \"\n                         f\"(not {arr.shape[0]} == {df.shape[0]})\")\n\n    XYM, domain = vars_from_df(df, role=role)\n\n    if role == Role.Attribute:\n        table.domain = Domain(domain.attributes,\n                              table.domain.class_vars,\n                              table.domain.metas)\n        table.X = XYM[0]\n    elif role == Role.ClassAttribute:\n        table.domain = Domain(table.domain.attributes,\n                              domain.class_vars,\n                              table.domain.metas)\n        table.Y = XYM[1]\n    else:  # if role == Role.Meta:\n        table.domain = Domain(table.domain.attributes,\n                              table.domain.class_vars,\n                              domain.metas)\n        table.metas = XYM[2]\n\n    if isinstance(df, OrangeDataFrame):\n        table.attributes.update(df.orange_attributes)\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
### Title: `table_from_frame` Fails to Replace NaN with `StringVariable.Unknown` for String Variables

#### Description
When converting a pandas DataFrame to an Orange Table using the `table_from_frame` function, NaN values in string columns are not being replaced with `StringVariable.Unknown`. Instead, these NaN values persist in the `metas`, leading to assertion failures and inconsistent data representation.

**Example Buggy Code:**
```python
import pandas as pd
from Orange.data import table_from_frame, StringVariable

# Create a DataFrame with NaN values in string columns
df = pd.DataFrame([
    ['a', 'b'],
    ['c', 'd'],
    ['e', 'f'],
    [5, 'c'],
    [None, None]  # NaN values
], columns=['s1', 's2']).astype({'s1': 'object', 's2': 'string'})

# Convert DataFrame to Orange Table
table = table_from_frame(df)

# Inspect metas to check for StringVariable.Unknown
print(table.metas)
```

**Expected Behavior:**
All NaN values in string columns (`s1` and `s2`) should be replaced with `StringVariable.Unknown` within the `metas` of the resulting Orange Table. This ensures consistency and prevents issues in downstream processing and testing.

**Actual Behavior:**
NaN values remain in the `metas` instead of being replaced with `StringVariable.Unknown`. This causes tests that expect `StringVariable.Unknown` to fail, as seen in the following assertion errors:

- `TestPandasCompat.test_table_from_frame` expects `[['a'], ['b'], ['c'], [StringVariable.Unknown]]` but receives `nan` instead.
- `TestPandasCompat.testa_table_from_frame_string` expects `[['a', 'b'], ['c', 'd'], ['e', 'f'], ['5', 'c'], [StringVariable.Unknown, StringVariable.Unknown]]` but finds NaN values.

#### Steps to Reproduce
1. Create a pandas DataFrame with NaN values in string-type columns.
2. Use the `table_from_frame` function to convert the DataFrame to an Orange Table.
3. Inspect the `metas` attribute of the resulting Table to observe the presence of NaN values instead of `StringVariable.Unknown`.

#### Impact
This issue leads to inconsistent data handling within Orange Tables, causing failed assertions in tests and potential data integrity problems in applications relying on these Tables.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/data/pandas_compat.py
"""Pandas DataFrame↔Table conversion helpers"""
from unittest.mock import patch

import numpy as np
from pandas.core.dtypes.common import is_string_dtype
from scipy import sparse as sp
from scipy.sparse import csr_matrix
import pandas as pd
from pandas.core.arrays import SparseArray
from pandas.core.arrays.sparse.dtype import SparseDtype
from pandas.api.types import (
    is_categorical_dtype, is_object_dtype,
    is_datetime64_any_dtype, is_numeric_dtype, is_integer_dtype
)

from Orange.data import (
    Table, Domain, DiscreteVariable, StringVariable, TimeVariable,
    ContinuousVariable,
)
from Orange.data.table import Role

__all__ = ['table_from_frame', 'table_to_frame']


class OrangeDataFrame(pd.DataFrame):
    _metadata = ["orange_variables", "orange_weights",
                 "orange_attributes", "orange_role"]

    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 __patch_constructor(self, method):
        def new_method(*args, **kwargs):
            with patch(
                    'pandas.DataFrame',
                    OrangeDataFrame
            ):
                df = method(*args, **kwargs)
            df.__finalize__(self)
            return df

        return new_method

    @property
    def _constructor(self):
        return OrangeDataFrame

    def to_orange_table(self):
        return table_from_frame(self)

    def __finalize__(self, other, method=None, **_):
        """
        propagate metadata from other to self

        Parameters
        ----------
        other : the object from which to get the attributes that we are going
            to propagate
        method : optional, a passed method name ; possibly to take different
            types of propagation actions based on this

        """
        if method == 'concat':
            objs = other.objs
        elif method == 'merge':
            objs = other.left, other.right
        else:
            objs = [other]

        orange_role = getattr(self, 'orange_role', None)
        dicts = {dname: getattr(self, dname, {})
                 for dname in ('orange_variables',
                               'orange_weights',
                               'orange_attributes')}
        for obj in objs:
            other_role = getattr(obj, 'orange_role', None)
            if other_role is not None:
                orange_role = other_role

            for dname, dict_ in dicts.items():
                other_dict = getattr(obj, dname, {})
                dict_.update(other_dict)

        object.__setattr__(self, 'orange_role', orange_role)
        for dname, dict_ in dicts.items():
            object.__setattr__(self, dname, dict_)

        return self

    pd.DataFrame.__finalize__ = __finalize__


def _reset_index(df: pd.DataFrame) -> pd.DataFrame:
    """If df index is not a simple RangeIndex (or similar), include it into a table"""
    if (
        # not range-like index - test first to skip slow startswith(_o) check
        not (
            df.index.is_integer()
            and (df.index.is_monotonic_increasing or df.index.is_monotonic_decreasing)
        )
        # check that it does not contain Orange index
        and (
            # startswith is slow (for long dfs) - firs check if col has strings
            isinstance(df.index, pd.MultiIndex)
            or not is_string_dtype(df.index)
            or not any(str(i).startswith("_o") for i in df.index)
        )
    ):
        df = df.reset_index()
    return df


def _is_discrete(s, force_nominal):
    return (is_categorical_dtype(s) or
            is_object_dtype(s) and (force_nominal or
                                    s.nunique() < s.size ** .666))


def _is_datetime(s):
    if is_datetime64_any_dtype(s):
        return True
    try:
        if is_object_dtype(s):
            # pd.to_datetime would sucessfuly parse column of numbers to datetime
            # but for column of object dtype with numbers we want to be either
            # discret or string - following code try to parse column to numeric
            # if connversion to numeric is sucessful return False
            try:
                pd.to_numeric(s)
                return False
            except (ValueError, TypeError):
                pass

            # utc=True - to allow different timezones in a series object
            pd.to_datetime(s, infer_datetime_format=True, utc=True)
            return True
    except Exception:  # pylint: disable=broad-except
        pass
    return False


def _convert_datetime(series, var):
    def col_type(dt):
        """Test if is date, time or datetime"""
        dt_nonnat = dt[~pd.isnull(dt)]  # nat == nat is False
        if (dt_nonnat.dt.floor("d") == dt_nonnat).all():
            # all times are 00:00:00.0 - pure date
            return 1, 0
        elif (dt_nonnat.dt.date == pd.Timestamp("now").date()).all():
            # all dates are today's date - pure time
            return 0, 1  # pure time
        else:
            # else datetime
            return 1, 1

    try:
        dt = pd.to_datetime(series)
    except ValueError:
        # series with type object and different timezones will raise a
        # ValueError - normalizing to utc
        dt = pd.to_datetime(series, utc=True)

    # set variable type to date, time or datetime
    var.have_date, var.have_time = col_type(dt)

    if dt.dt.tz is not None:
        # set timezone if available and convert to utc
        var.timezone = dt.dt.tz
        dt = dt.dt.tz_convert("UTC")

    if var.have_time and not var.have_date:
        # if time only measure seconds from midnight - equal to setting date
        # to unix epoch
        return (
            (dt.dt.tz_localize(None) - pd.Timestamp("now").normalize())
            / pd.Timedelta("1s")
        ).values

    return (
        (dt.dt.tz_localize(None) - pd.Timestamp("1970-01-01")) / pd.Timedelta("1s")
    ).values


def to_categorical(s, _):
    x = s.astype("category").cat.codes
    # it is same than x.replace(-1, np.nan), but much faster
    x = x.where(x != -1, np.nan)
    return np.asarray(x)


def vars_from_df(df, role=None, force_nominal=False):
    if role is None and hasattr(df, 'orange_role'):
        role = df.orange_role
    df = _reset_index(df)

    cols = [], [], []
    exprs = [], [], []
    vars_ = [], [], []

    for column in df.columns:
        s = df[column]
        _role = Role.Attribute if role is None else role
        if hasattr(df, 'orange_variables') and column in df.orange_variables:
            original_var = df.orange_variables[column]
            var = original_var.copy(compute_value=None)
            expr = None
        elif _is_datetime(s):
            var = TimeVariable(str(column))
            expr = _convert_datetime
        elif _is_discrete(s, force_nominal):
            discrete = s.astype("category").cat
            var = DiscreteVariable(
                str(column), discrete.categories.astype(str).tolist()
            )
            expr = to_categorical
        elif is_numeric_dtype(s):
            var = ContinuousVariable(
                # set number of decimals to 0 if int else keeps default behaviour
                str(column), number_of_decimals=(0 if is_integer_dtype(s) else None)
            )
            expr = None
        else:
            if role is not None and role != Role.Meta:
                raise ValueError("String variable must be in metas.")
            _role = Role.Meta
            var = StringVariable(str(column))
            expr = lambda s, _: np.asarray(s, dtype=object)

        cols[_role].append(column)
        exprs[_role].append(expr)
        vars_[_role].append(var)

    xym = []
    for a_vars, a_cols, a_expr in zip(vars_, cols, exprs):
        if not a_cols:
            arr = None if a_cols != cols[0] else np.empty((df.shape[0], 0))
        elif not any(a_expr):
            # if all c in columns table will share memory with dataframe
            a_df = df if all(c in a_cols for c in df.columns) else df[a_cols]
            if all(isinstance(a, SparseDtype) for a in a_df.dtypes):
                arr = csr_matrix(a_df.sparse.to_coo())
            else:
                arr = np.asarray(a_df)
        else:
            # we'll have to copy the table to resolve any expressions
            arr = np.array(
                [
                    expr(df[col], var) if expr else np.asarray(df[col])
                    for var, col, expr in zip(a_vars, a_cols, a_expr)
                ]
            ).T
        xym.append(arr)

    # Let the tables share memory with pandas frame
    if xym[1] is not None and xym[1].ndim == 2 and xym[1].shape[1] == 1:
        xym[1] = xym[1][:, 0]

    return xym, Domain(*vars_)


def table_from_frame(df, *, force_nominal=False):
    XYM, domain = vars_from_df(df, force_nominal=force_nominal)

    if hasattr(df, 'orange_weights') and hasattr(df, 'orange_attributes'):
        W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]
        if len(W) != len(df.index):
            W = None
        attributes = df.orange_attributes
        if isinstance(df.index, pd.MultiIndex) or not is_string_dtype(df.index):
            # we can skip checking for Orange indices when MultiIndex an when
            # not string dtype and so speedup the conversion
            ids = None
        else:
            ids = [
                int(i[2:])
                if str(i).startswith("_o") and i[2:].isdigit()
                else Table.new_id()
                for i in df.index
            ]
    else:
        W = None
        attributes = None
        ids = None

    return Table.from_numpy(
        domain,
        *XYM,
        W=W,
        attributes=attributes,
        ids=ids
    )


def table_from_frames(xdf, ydf, mdf):
    if not (xdf.index.equals(ydf.index) and xdf.index.equals(mdf.index)):
        raise ValueError(
            "Indexes not equal. Make sure that all three dataframes have equal index"
        )

    # drop index from x and y - it makes sure that index if not range will be
    # placed in metas
    xdf = xdf.reset_index(drop=True)
    ydf = ydf.reset_index(drop=True)
    dfs = xdf, ydf, mdf

    if not all(df.shape[0] == xdf.shape[0] for df in dfs):
        raise ValueError(f"Leading dimension mismatch "
                         f"(not {xdf.shape[0]} == {ydf.shape[0]} == {mdf.shape[0]})")

    xXYM, xDomain = vars_from_df(xdf, role=Role.Attribute)
    yXYM, yDomain = vars_from_df(ydf, role=Role.ClassAttribute)
    mXYM, mDomain = vars_from_df(mdf, role=Role.Meta)

    XYM = (xXYM[0], yXYM[1], mXYM[2])
    domain = Domain(xDomain.attributes, yDomain.class_vars, mDomain.metas)

    ids = [
        int(idx[2:])
        if str(idx).startswith("_o") and idx[2:].isdigit()
        else Table.new_id()
        for idx in mdf.index
    ]

    attributes = {}
    W = None
    for df in dfs:
        if isinstance(df, OrangeDataFrame):
            W = [df.orange_weights[i] for i in df.index if i in df.orange_weights]
            if len(W) != len(df.index):
                W = None
            attributes.update(df.orange_attributes)
        else:
            W = None

    return Table.from_numpy(
        domain,
        *XYM,
        W=W,
        attributes=attributes,
        ids=ids
    )


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_frames(table):
    xdf = OrangeDataFrame(table, Role.Attribute)
    ydf = OrangeDataFrame(table, Role.ClassAttribute)
    mdf = OrangeDataFrame(table, Role.Meta)

    return xdf, ydf, mdf


def amend_table_with_frame(table, df, role):
    arr = Role.get_arr(role, table)
    if arr.shape[0] != df.shape[0]:
        raise ValueError(f"Leading dimension mismatch "
                         f"(not {arr.shape[0]} == {df.shape[0]})")

    XYM, domain = vars_from_df(df, role=role)

    if role == Role.Attribute:
        table.domain = Domain(domain.attributes,
                              table.domain.class_vars,
                              table.domain.metas)
        table.X = XYM[0]
    elif role == Role.ClassAttribute:
        table.domain = Domain(table.domain.attributes,
                              domain.class_vars,
                              table.domain.metas)
        table.Y = XYM[1]
    else:  # if role == Role.Meta:
        table.domain = Domain(table.domain.attributes,
                              table.domain.class_vars,
                              domain.metas)
        table.metas = XYM[2]

    if isinstance(df, OrangeDataFrame):
        table.attributes.update(df.orange_attributes)

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user