Can we add support for negative units on cut() and probably others?

rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 563 Unicorn
Well, today I had an interesting, super simple case. I had the following strings:

Enero 2016
Febrero 2016
Marzo 2016
Abril 2016
...

Those are strings that define "periods" (months, as "enero" is January, etc...) but not exactly dates (as this is the name of the period for an invoice, and therefore it's treated like a categorical variable, but the actual reading date for January 2016 could be 30 December 2015 and the emission date could be 2 February 2016, so there is no need to use a date expression to define it).

I wanted to obtain just the portion of the string that says "2016" at the end with the "Generate Attributes" operator (there is plenty of ways to do that, but I kinda like to use some programming to generate a new attribute). To my dismay, the syntax for cut does not allow negative numbers, so I couldn't do the following:

cut("Periodo", 0, -4)
I think this is very specific, might not be relevant, and it can make the bottom of the priority list of features but... IDK, can this be added? it's just that I'm used to have these things in other programming languages, I thought it can just be a nice thing to have.

All the best,

Rod.
Tagged:
BalazsBaranyJasmine_

Best Answers

Answers

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 814 Unicorn
    The negative offset syntax is quite common in other expression languages to refer to "count from the end". I like this idea very much.
    Jasmine_rfuentealba
  • rfuentealbarfuentealba Moderator, RapidMiner Certified Analyst, Member, University Professor Posts: 563 Unicorn
    Thanks to both, I didn't know about suffix()!

    I appreciate the timely answers too.

    All the best,

    Rod.
    sgenzerJasmine_
Sign In or Register to comment.