"Generate Attribute problems - Solved"

ypalrecha
ypalrecha New Altair Community Member
edited November 5 in Community Q&A

Trying to extract month and year using generate attribute. It wont extract Dec month as 12. It extracts as 11. Is there a bug with this operator or expression?


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.008">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
   <process expanded="true" height="386" width="611">
     <operator activated="false" class="retrieve" compatibility="5.2.008" expanded="true" height="60" name="Retrieve" width="90" x="45" y="165">
       <parameter key="repository_entry" value="//MehekRepo/Data/Orlando_2001_2012_Weather"/>
     </operator>
     <operator activated="true" class="read_csv" compatibility="5.2.008" expanded="true" height="60" name="Read CSV" width="90" x="118" y="36">
       <parameter key="csv_file" value="/data/rapidminer/WeatherGround/Orlando_2001_2012.csv"/>
       <parameter key="column_separators" value=","/>
       <parameter key="date_format" value="yyyy-MM-dd"/>
       <parameter key="first_row_as_names" value="false"/>
       <list key="annotations">
         <parameter key="0" value="Name"/>
       </list>
       <parameter key="encoding" value="MacRoman"/>
       <list key="data_set_meta_data_information">
         <parameter key="0" value="Date.true.date.id"/>
         <parameter key="1" value="Max TemperatureF.true.integer.attribute"/>
         <parameter key="2" value="Mean TemperatureF.true.integer.attribute"/>
         <parameter key="3" value="Min TemperatureF.true.integer.attribute"/>
         <parameter key="4" value="Max Dew PointF.true.integer.attribute"/>
         <parameter key="5" value="MeanDew PointF.true.integer.attribute"/>
         <parameter key="6" value="Min DewpointF.true.integer.attribute"/>
         <parameter key="7" value="Max Humidity.true.integer.attribute"/>
         <parameter key="8" value="Mean Humidity.true.integer.attribute"/>
         <parameter key="9" value="Min Humidity.true.integer.attribute"/>
         <parameter key="10" value="Max Sea Level PressureIn.true.real.attribute"/>
         <parameter key="11" value="Mean Sea Level PressureIn.true.real.attribute"/>
         <parameter key="12" value="Min Sea Level PressureIn.true.real.attribute"/>
         <parameter key="13" value="Max VisibilityMiles.true.integer.attribute"/>
         <parameter key="14" value="Mean VisibilityMiles.true.integer.attribute"/>
         <parameter key="15" value="Min VisibilityMiles.true.integer.attribute"/>
         <parameter key="16" value="Max Wind SpeedMPH.true.integer.attribute"/>
         <parameter key="17" value="Mean Wind SpeedMPH.true.integer.attribute"/>
         <parameter key="18" value="Max Gust SpeedMPH.true.integer.attribute"/>
         <parameter key="19" value="PrecipitationIn.true.real.attribute"/>
         <parameter key="20" value="CloudCover.true.integer.attribute"/>
         <parameter key="21" value="Events.true.polynominal.attribute"/>
         <parameter key="22" value="WindDirDegrees.true.integer.attribute"/>
       </list>
     </operator>
     <operator activated="true" breakpoints="after" class="generate_attributes" compatibility="5.2.008" expanded="true" height="76" name="Generate Attributes" width="90" x="179" y="120">
       <list key="function_descriptions">
         <parameter key="Month" value="date_get(Date,DATE_UNIT_MONTH)"/>
         <parameter key="Year" value="date_get(Date,DATE_UNIT_YEAR)"/>
       </list>
     </operator>
     <operator activated="true" class="aggregate" compatibility="5.2.008" expanded="true" height="76" name="Aggregate" width="90" x="246" y="255">
       <list key="aggregation_attributes">
         <parameter key="Mean TemperatureF" value="average"/>
       </list>
       <parameter key="group_by_attributes" value="Month|Year"/>
     </operator>
     <connect from_op="Read CSV" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
     <connect from_op="Generate Attributes" from_port="example set output" to_op="Aggregate" to_port="example set input"/>
     <connect from_op="Aggregate" 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"/>
   </process>
 </operator>
</process>

Answers

  • MariusHelf
    MariusHelf New Altair Community Member
    Hi,

    the date_get method starts with January as 0, February 1, etc. If you want the usual months as humans would count them, you have to add "+1" to your expression.

    Best, Marius
  • ypalrecha
    ypalrecha New Altair Community Member
    Thanks a lot. Had I seen Nov value I would have figured this out. Seems little wierd though.