Group/Rename Examples
Hello,
I am still preparing my data and would like to rename examples that belong to a same group within one colum:
1 | Audi, A6 | 677 |
2 | March | 140 |
3 | 2018 | 70 |
4 | Dezember | 51 |
5 | Audi, A2 | 9 |
6 | 2016 | 9 |
7 | BMW, 3er | 7 |
8 | BMW, X5 | 1 |
Later:
1 | Audi | 677 |
2 | Month | 140 |
3 | Year | 70 |
4 | Month | 51 |
5 | Audi | 9 |
6 | Year | 9 |
7 | BMW | 7 |
8 | BMW | 1 |
I know that you might do this with Regular Expressions and also in a different way for date types, but I couldn`t figure it out.
Thanks for your help !
Best Answer
-
Telcontar120 RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 Unicorn
If you can write a set of logical rules (IF/THEN/AND/OR/NOR) to express the conditions under which these substitutions should occur, then you can accomplish it with "Generate Attributes". For example, you could use the "contains" function for string searching and then supply supplemental conditions.
However, if you can't express the renaming subsitutions in a set of rules, and the format of the cell content is not consistent (such that you could use Replace with regex as already suggested), then I am not sure how you would expect a computer program to execute your desires? You might need to use Map and do it "manually" instead.
2
Answers
Hi, @t_liebe
This is easy:
Use the Replace operator and put the following on the Parameters panel:
Basically, you are trying to read two groups (.*) and (.*), separated by a comma, and use the first one ($1) as the output of your data.
All the best,
Rodrigo.
Yes I tried that as well, but didn't fit my problem. I think I didn't give you enough information, sorry for that.
This what it looks like:
xxxx xxxx Audi xxx
Audixxx, xxxx, xxxx
Audixxx
xxxAudi
So the "Audi" is just a part of the example, but I am not interested in the other parts of the example.
I hope this explains a little bit more.