convert collection to a single table (ExampleSet)

acuriel
acuriel New Altair Community Member
edited November 5 in Community Q&A
I'm using loop values and it generates different tables (ExampleSet) by value with the same attributes.
I need to have a table with all.

my out is

collection

table value 23: 
                  USER_ID  ITEM_ID
                  1          23

table value 54:
              USER_ID  ITEM_ID
                  1          54
...                     

I need this

ExampleSet
 
              USER_ID  ITEM_ID
                  1          23
                  1          54
                  ...        ...

Thanks

Answers

  • Marco_Boeck
    Marco_Boeck New Altair Community Member
    Hi,

    you've posted in the Development forum, so I'm assuming you want to know how to do it in Java. You will need to create a new ExampleSet with the same attributes as your existing sets have. You can then loop over each example (row) of each example set and add a row for each to the new one. See below for a quick example:

    MemoryExampleTable table = new MemoryExampleTable(listOfAtts);

    for (ExampleSet exSet : listOfExampleSets) {
    for (Example e : exSet) {
    table.addDataRow(e.getDataRow());
    }
    }

    ExampleSet exSet = table.createExampleSet();
    In case you were looking for a solution inside RapidMiner Studio, just use the "Append" operator.

    Regards,
    Marco
  • VinayakThote
    VinayakThote New Altair Community Member
    Append is also giving single collection object
    Whats the solution?? I want single example set.

  • BalazsBarany
    BalazsBarany New Altair Community Member
    Hi,

    if you use Append correctly, it will give you an example set. This is working every time in hundreds of processes.

    Please post a screenshot and the process XML if it doesn't work for you.

    Regards,
    Balázs
  • machbrown2
    machbrown2 New Altair Community Member
    Hello,

    It sounds like you want to concatenate or combine the tables generated for different values into a single table in your Example Set. If you are using a programming language or a tool that supports loops, you can achieve this by appending the tables for each value. Here's a general example using Python and pandas:
    </code>import pandas as pd # Initialize an empty DataFrame to store the combined tables combined_table = pd.DataFrame(columns=["USER_ID", "ITEM_ID"]) # Example loop (replace this with your actual loop) for value in [23, 54, ...]: # Add all your loop values # Assuming you have a function to generate each table based on the loop value table_for_value = generate_table(value) # Append the table for the current value to the combined_table combined_table = pd.concat([combined_table, table_for_value], ignore_index=True) # Display the combined table print(combined_table)</pre><div><br>In this example:<br><ul><li>Replace <code>[23, 54, ...] with the actual values you are looping through.Replace generate_table(value) with the function or code that generates the table for each value.The pd.concat function is used to concatenate the tables vertically (row-wise). The ignore_index=True parameter ensures that the resulting DataFrame has a new index.Note: The exact implementation may vary based on the language or tool you are using. If you provide more details about your environment, I can offer a more specific solution.