Remove dollar sign from nominal currency value?

tmyerstmyers Member Posts: 21 Contributor II
edited November 2018 in Help

Hi. I have a nominal attribute containing a currency value including a dollar sign (e.g. $1.23). I would like to convert this attribute to a simple Numerical value without the dollar sign (e.g. 1.23) to use in subsequent calculations.


What is the easiest way to do this conversion in Rapidminer? I was trying to remove the "$" from the text string before parsing the number, but I'm presuming there has to be a simpler way to do this conversion.............................?


Any tips would be appreciated, thanks.



Best Answer

  • Options
    yyhuangyyhuang Administrator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 364 RM Data Scientist
    Solution Accepted

    Hi Tmyers,


    The sample process is here


    <?xml version="1.0" encoding="UTF-8"?><process version="7.3.000">
    <operator activated="true" class="process" compatibility="7.3.000" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="generate_sales_data" compatibility="7.3.000" expanded="true" height="68" name="Generate Sales Data" width="90" x="112" y="34">
    <parameter key="number_examples" value="10"/>
    <operator activated="true" class="numerical_to_polynominal" compatibility="7.3.000" expanded="true" height="82" name="Numerical to Polynominal" width="90" x="246" y="34">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="single_price"/>
    <operator activated="true" breakpoints="after" class="generate_attributes" compatibility="7.3.000" expanded="true" height="82" name="Generate Attributes" width="90" x="380" y="34">
    <list key="function_descriptions">
    <parameter key="single_price_with_dollar" value="concat(&quot;$&quot;,single_price)"/>
    <description align="center" color="transparent" colored="false" width="126">Put '$' in front of single price</description>
    <operator activated="true" class="replace" compatibility="7.3.000" expanded="true" height="82" name="Replace" width="90" x="514" y="34">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="single_price_with_dollar"/>
    <parameter key="replace_what" value="\$"/>
    <description align="center" color="transparent" colored="false" width="126">Get rid of '$' sign</description>
    <operator activated="true" class="parse_numbers" compatibility="7.3.000" expanded="true" height="82" name="Parse Numbers" width="90" x="648" y="34">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="single_price_with_dollar"/>
    <connect from_op="Generate Sales Data" from_port="output" to_op="Numerical to Polynominal" to_port="example set input"/>
    <connect from_op="Numerical to Polynominal" from_port="example set output" to_op="Generate Attributes" to_port="example set input"/>
    <connect from_op="Generate Attributes" from_port="example set output" to_op="Replace" to_port="example set input"/>
    <connect from_op="Replace" from_port="example set output" to_op="Parse Numbers" to_port="example set input"/>
    <connect from_op="Parse Numbers" from_port="example set output" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>




  • Options
    sgenzersgenzer Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager

    Oh there's a few ways to do that.  The easiest is probably to do a Replace (to get rid of $) followed by Parse Numbers.  I would probably do it in a Generate Attributes expression which I can show you if you want.





Sign In or Register to comment.