Pandas dataframe to Orange table with setting role (feature or target)

Viewed 408

I have a dataframe as follows

df = pd.DataFrame({"A": ["a", "b", "c"], "B": ["d", "e", "f"], "C": ["yes", "no", "yes"]})

I would like to convert df to orange table and set A and B as categorical attributes and then set C as the class variable (target variable). Currently, I can convert to a pandas dataframe using

from Orange.data.pandas_compat import table_from_frame
orange_table = table_from_frame(df)

It converts df successfully to an orange table but I could not set the role for each column. May I have your suggestions?

1 Answers

You can simply output the Orange table from the Python Script widget.

out_data=orange_table

Then use the Select Column widget to select the features and target variable.

orange select column widget example

Related