Dates / Date_parse / Automodel Preprocessing
Hi All-
I have a process, exported from AutoModel, that decomposes all dates into attributes like "date_name:month_of_year", "date_name:year", "date_name:day_of_month", etc. I'm trying to recoup the original dates from the underlying data (thinking this would be "easy" to do by stringing a bunch of concat() s together and feeding them to date_parse()... e.g. concat(concat(date_name:month_of_year,"/"),date_name:day_of_month))...
This is turning out to be more difficult than anticipated. Any suggestions for a different approach?
Thanks, Noel
I have a process, exported from AutoModel, that decomposes all dates into attributes like "date_name:month_of_year", "date_name:year", "date_name:day_of_month", etc. I'm trying to recoup the original dates from the underlying data (thinking this would be "easy" to do by stringing a bunch of concat() s together and feeding them to date_parse()... e.g. concat(concat(date_name:month_of_year,"/"),date_name:day_of_month))...
This is turning out to be more difficult than anticipated. Any suggestions for a different approach?
Thanks, Noel
Tagged:
0
Best Answer
-
tftemme Administrator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, RMResearcher, MemberPosts:164RM ResearchHi@Noel
Concerning the problem with the parsing. I am not sure what exactly goes wrong. So I am assuming here that maybe the parsing of the numerical month_of, day_of, year_of attributes for the concat is not working. So you have to add a str() function around the attributes. Also I would use the date_parse_custom function to explicitly specify the format of the string to be parsed into the date.
Another possibility is to use the Nominal to Date operator (where you also have to specify the date format of the nominal attribute).
I attached an xml file where I created random 'month of year', 'day of year', 'year' attributes and then use generate attribute to concat them to the date string. In the Generate Attribute I directly use this date string with date_parse_custom to convert it into a date_time attribute. For demonstrating I am doing the same again with the Nominal to Date operator.
Concerning the attribute names with white spaces. You just need to put them into squared brackets (can see this in the example xml below), then the function expression can correctly identify them. When you use the expression editor (small calculator symbol) and insert an attribute in your function by using the list in the bottom right, the squared brackets are inserted automatically, if needed.
Hopes this helps. Best regards,
Fabian
7
Answers
Dortmund, Germany