Convert and compare - Date and Time

mengkoon007mengkoon007 MemberPosts:30Contributor I
edited November 2018 inHelp

Hi,

I have a dataset with 2 columns (Date and Time):

Date showing "1/1/2016", "23/4/2016".

Time showing "12:04:06 PM", "7:12:23 AM".

Question: I would like to show that any data with date (earlier than 3/2/2016) or time (earlier than 9:00:00 AM), a status will show "1" else show "2", I tried below but having error. May I know which area I have done wrongly and can the display be kept as original?

====

1. I import the data and noticed that the data type is polynominal for the date and time.

2. Thus, I used the data transformation "Nominal to Date":

a) For date, i convert to "date" data type with date format as "dd/mm/yyyy"

b) For time, I convert to "time" data type with date format as "hh:mm:ss a"

3. I used generate attribute to do comparison.

a) attribute name: status

b) function expression: if(Date<"3/2/2016" || Time<"9:00:00 AM",1,2)

However, I received the following error:

error.gif

Tagged:

Answers

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, MemberPosts:1,761Unicorn

    I think you need to use the eval() function for this, which I don't think is available in the version you are using. It appears you are using v5.3?

    Pavithra_Rao
  • sshah8050sshah8050 MemberPosts:1Contributor I
    Hi,

    I have three Attribute Day, Month, and Year. i want to get it like 22/12/2018. do we have any function for it?


  • IngoRMIngoRM Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University ProfessorPosts:1,751RM Founder
    Hi,
    Sure, you can use a combination of the operators Generate Attributes and Nominal to Date. Below is an example process showing this.
    Hope this helps,
    Ingo
    < ?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程版本sion="9.2.001">
     
       
       
       
     

     
       
       
       
       
       
       
       
         
           
           
           
           
           
           
           
           
           
           
           
           
           
           
           
         

         
           
             
           

           
         

         
           
           
           
           
           
           
         

         
         
         
         
         
         
       

     

  • varunm1varunm1 Moderator, MemberPosts:1,207Unicorn
    edited April 2019
    Hello@sshah8050

    You can concatenate these three attributes (attributes should be of type nominal) using Generate attributes operator into a single attribute and then parse it (if you need it as a date datatype) into a date using Nominal to date operator. Sample XML code below.

    < ?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程版本sion="9.2.001">
















    <操作符= " true " class = " generate_attribu激活tes" compatibility="9.2.001" expanded="true" height="82" name="Generate Attributes" width="90" x="447" y="85">



    <参数键= "柯ep_all" value="true"/>







    <参数键= "柯ep_old_attribute" value="false"/>










    Thanks
    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

    IngoRM hughesfleming68
  • PapadPapad MemberPosts:68Guru
    Hello@sshah8050
    For transformations and data types you can also use turbo prep and then go in your process.

    MartinLiebig IngoRM
Sign InorRegisterto comment.