The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Change value order?
Best Answer
-
Edin_Klapic Employee-RapidMiner, RMResearcher, Member Posts: 299 RM Data Scientist
Hi Philipp,
Within Generate Attributes everything between double quotes is interpreted as a string. So the function wants to parse the string Day (and not the attribute with the name Day) to a date which creates the error.
Assuming the value type of Day is nominal the solution would therefore be
date_str_custom(date_parse_custom(Day,"M/d/y
y"),"dd.MM.yy") Best,
Edin
2
Answers
Hey,
do you mean attribute order? If yes, reorder attributes is the operator. Or do you to sort a string?
~Martin
Dortmund, Germany
Hey,
you can go for a Replace operator with a regex
(\d+).(\d+).(\d+)
and replace it with
$2.$1.$3
Edit: I think the Excel mid is similar than cut() in Generate Attributes, if you prefer this.
Best,
Martin
Dortmund, Germany
Regex worked pretty well. Going a step further what I wanted to achieve was to convert the english date into a german one so:
12/3/16 (mm/dd/yy) in 03.12.16
I replaced the "/" with dots and changed the order of day and month with the regex-replace. Now to further work with this date in excel it should be in the named format (above). Unfortunately it is in the format 3.12.16, thus the zeros are missing.
My question is how can I get the zeros in the date and if this way of achieving this is even good to do so, because I think this is somehow very complicated to just transform english date into a german one.
Thank you
Philipp
Hey,
i think its just another regex with Replace:
0(\d)
replace with
$1
Attached is a process doing it.
~Martin
Dortmund, Germany
Hi Philipp,
I suggest the usage of the Generate Attributes Operator and the built-in date conversion functions.
The following expression converts the nominal value "12/3/16" into the desired nominal output format "03.12.16".
date_str_custom(date_parse_custom("12/3/16","M/d/yy"),"dd.MM.yy")
Simply replace the string with the attribute name and you are set
Best regards,
Edin
But then he "deletes" the zeros? I tried it and nothing really changed. The process you posted unfortunately doesn't work. It says "Day not found".
Although I am sure that you will get there with regex I think Edin's solution above is the simplest approach...
Thank you Edin,
y"),"dd.MM.yy")
that soundy very useful. When I replace the string (name of the attribute is "Day")
date_str_custom(date_parse_custom("Day","M/d/y
I get the error: "invalid_argument.date." and the process stops.
Do you know where there could be a mistake?
Philipp