🥳 RAPIDMINER 9.9 IS OUT!!! 🥳

The updates in 9.9 power advanced use cases and offer productivity enhancements for users who prefer to code.

CLICK HERE TO DOWNLOAD

How can we re-order the elements in one list with respect to other list?

AnushaAnusha Member Posts: 15  Maven
Hi All!

I have a data set that has 5 columns. the first column is the ID and all other columns have concatenated data. so, I just reorder one column with respect to another column based on common values also.
here ch_1 is having terms and their respective values are present in va_1 in the same order and also the same for ch_2 & va_2.
ch_2 terms having their values in va_2.

if we change the order of terms in ch_1&ch_2, values order also should change in values columns va_1&va_2.


source data:


no                ch_1             ch_2                va_1                      va_2
123             sh|;ty|;hi        hi|;sh                  8|;"cir"|;89             98|;8

required output:

no             ch_1              ch_2                   va_1                       va_2
123            sh|;hi|;ty         sh|;hi                   8|;89|;"cir                8|;98\


if we split the data based on separator we may have source data differently

after twisting the source data:
no              ch_1                 ch_2               va_1                   va_2
123             sh                    hi                    8                          98
123            ty                     sh                       cir                     8
123             hi                     ?                       89                     ?

here also how can get the same order for both ch_1&ch_2 and respective va_1&va_2 should also be changed.

output required:

no              ch_1                 ch_2               va_1                   va_2
123             sh                    sh                    8                          8
123            ty                     ?                       cir                     ?
123             hi                     hi                      89                     98


can anyone help to solve this either with source data/ twisted data?

Thanks in Advance!


Answers

  • yyhuangyyhuang Administrator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 347  RM Data Scientist
    How about de-pivoting and always keep 1-to-1 mapping between ch* and va*?

    <?xml version="1.0" encoding="UTF-8"?><process version="9.9.002">

      <context>

        <input/>

        <output/>

        <macros/>

      </context>

      <operator activated="true" class="process" compatibility="9.9.002" expanded="true" name="Process">

        <parameter key="logverbosity" value="init"/>

        <parameter key="random_seed" value="2001"/>

        <parameter key="send_mail" value="never"/>

        <parameter key="notification_email" value="[email protected]"/>

        <parameter key="process_duration_for_mail" value="1"/>

        <parameter key="encoding" value="UTF-8"/>

        <process expanded="true">

          <operator activated="true" class="utility:create_exampleset" compatibility="9.9.002" expanded="true" height="68" name="Create ExampleSet" width="90" x="112" y="34">

            <parameter key="generator_type" value="comma separated text"/>

            <parameter key="number_of_examples" value="100"/>

            <parameter key="use_stepsize" value="false"/>

            <list key="function_descriptions"/>

            <parameter key="add_id_attribute" value="false"/>

            <list key="numeric_series_configuration"/>

            <list key="date_series_configuration"/>

            <list key="date_series_configuration (interval)"/>

            <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>

            <parameter key="time_zone" value="SYSTEM"/>

            <parameter key="input_csv_text" value="no                ch_1             ch_2                va_1                      va_2&#10;123             sh|;ty|;hi        hi|;sh                  8|;cir|;89             98|;8&#10;126             sd|;tf&#9;         hi|;sh|df                  8|;89            &#9;   kd|98|;8"/>

            <parameter key="column_separator" value="\s+"/>

            <parameter key="parse_all_as_nominal" value="false"/>

            <parameter key="decimal_point_character" value="."/>

            <parameter key="trim_attribute_names" value="true"/>

          </operator>

          <operator activated="true" class="split" compatibility="9.9.002" expanded="true" height="82" name="Split" width="90" x="246" y="136">

            <parameter key="attribute_filter_type" value="all"/>

            <parameter key="attribute" value=""/>

            <parameter key="attributes" value=""/>

            <parameter key="use_except_expression" value="false"/>

            <parameter key="value_type" value="nominal"/>

            <parameter key="use_value_type_exception" value="false"/>

            <parameter key="except_value_type" value="file_path"/>

            <parameter key="block_type" value="single_value"/>

            <parameter key="use_block_type_exception" value="false"/>

            <parameter key="except_block_type" value="single_value"/>

            <parameter key="invert_selection" value="false"/>

            <parameter key="include_special_attributes" value="false"/>

            <parameter key="split_pattern" value="\|"/>

            <parameter key="split_mode" value="ordered_split"/>

          </operator>

          <operator activated="true" class="de_pivot" compatibility="9.9.002" expanded="true" height="82" name="De-Pivot" width="90" x="447" y="34">

            <list key="attribute_name">

              <parameter key="ch_1" value="ch_1.*"/>

              <parameter key="ch_2" value="ch_2.*"/>

              <parameter key="va_1" value="va_1.*"/>

              <parameter key="va_2" value="va_2.*"/>

            </list>

            <parameter key="index_attribute" value="index"/>

            <parameter key="create_nominal_index" value="false"/>

            <parameter key="keep_missings" value="true"/>

          </operator>

          <connect from_op="Create ExampleSet" from_port="output" to_op="Split" to_port="example set input"/>

          <connect from_op="Split" from_port="example set output" to_op="De-Pivot" to_port="example set input"/>

          <connect from_op="Split" from_port="original" to_port="result 3"/>

          <connect from_op="De-Pivot" from_port="example set output" to_port="result 1"/>

          <connect from_op="De-Pivot" from_port="original" to_port="result 2"/>

          <portSpacing port="source_input 1" spacing="0"/>

          <portSpacing port="sink_result 1" spacing="0"/>

          <portSpacing port="sink_result 2" spacing="0"/>

          <portSpacing port="sink_result 3" spacing="0"/>

          <portSpacing port="sink_result 4" spacing="0"/>

        </process>

      </operator>

    </process>


    lionelderkrikormschmitzEdin_Klapic
Sign In or Register to comment.