# Path: orangecontrib/spark/utils/data_utils.py
# def pandas_to_orange(df):
#     domain, attributes, metas = construct_domain(df)
#     orange_table = Orange.data.Table.from_numpy(domain = domain, X = df[attributes].values, Y = None, metas = df[metas].values, W = None)
#     return orange_table


from Orange.data import Table
from Orange.widgets import widget, gui, settings
from orangecontrib.spark.utils.data_utils import pandas_to_orange
import pandas
__author__ = 'jamh'



class OWPandasToOrange(widget.OWWidget):
    name = "from Pandas"
    description = "Convert Pandas DataFrame to Orange Table"
    icon = "../icons/orange-canvas.svg"
    inputs = [("Pandas", pandas.DataFrame, "get_input", widget.Default)]
    outputs = [("Table", Table, widget.Dynamic)]
    settingsHandler = settings.DomainContextHandler()

    def __init__(self):
        super().__init__()

# Path: orangecontrib/spark/utils/data_utils.py
# def pandas_to_orange(df):
#     domain, attributes, metas = construct_domain(df)
#     orange_table = Orange.data.Table.from_numpy(domain = domain, X = df[attributes].values, Y = None, metas = df[metas].values, W = None)
#     return orange_table


# Path: orangecontrib/spark/widgets/data/pandas_to_orange.py
from Orange.data import Table
from Orange.widgets import widget, gui, settings
from orangecontrib.spark.utils.data_utils import pandas_to_orange
import pandas

__author__ = 'jamh'



class OWPandasToOrange(widget.OWWidget):
    name = "from Pandas"
    description = "Convert Pandas DataFrame to Orange Table"
    icon = "../icons/orange-canvas.svg"
    inputs = [("Pandas", pandas.DataFrame, "get_input", widget.Default)]
    outputs = [("Table", Table, widget.Dynamic)]
    settingsHandler = settings.DomainContextHandler()

    def __init__(self):
        super().__init__()

        gui.label(self.controlArea, self, "from pandas:")