Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

Merging data in two columns based on IF condition

jeganathanvelujeganathanvelu Member Posts: 17 Contributor II
edited November 2018 in Help
Hi,

I need help in replicating a functionality as in MS Excel.

I have two data Columns A and B. I want to combine them into column C on the condition IF value of A is empty then copy value of B in C

Could you please guide me on how to do this in Rapid Miner??

Thanks in Advance,
Jegan.

Answers

  • JEdwardJEdward RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 578 Unicorn
    Here's an example using the Generate Attributes operator:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.015">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.3.015" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data_user_specification" compatibility="5.3.015" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="75">
            <list key="attribute_values">
              <parameter key="A" value="&quot;Jimmy&quot;"/>
              <parameter key="B" value="&quot;Stewart&quot;"/>
            </list>
            <list key="set_additional_roles"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.3.015" expanded="true" height="76" name="Generate Attributes" width="90" x="313" y="30">
            <list key="function_descriptions">
              <parameter key="C" value="if(missing(A),B,concat(A,B))"/>
            </list>
          </operator>
          <operator activated="true" class="generate_data_user_specification" compatibility="5.3.015" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="45" y="165">
            <list key="attribute_values">
              <parameter key="B" value="&quot;Stewart&quot;"/>
            </list>
            <list key="set_additional_roles"/>
          </operator>
          <operator activated="true" class="generate_empty_attribute" compatibility="5.3.015" expanded="true" height="76" name="Generate Empty Attribute" width="90" x="179" y="165">
            <parameter key="name" value="A"/>
            <parameter key="value_type" value="nominal"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.3.015" expanded="true" height="76" name="Generate Attributes (2)" width="90" x="380" y="165">
            <list key="function_descriptions">
              <parameter key="C" value="if(missing(A),B,concat(A,B))"/>
            </list>
          </operator>
          <connect from_op="Generate Data by User Specification" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" to_port="result 1"/>
          <connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Generate Empty Attribute" to_port="example set input"/>
          <connect from_op="Generate Empty Attribute" from_port="example set output" to_op="Generate Attributes (2)" to_port="example set input"/>
          <connect from_op="Generate Attributes (2)" from_port="example set output" 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"/>
        </process>
      </operator>
    </process>
  • jeganathanvelujeganathanvelu Member Posts: 17 Contributor II
    Thanks JEdward it worked.
Sign In or Register to comment.