🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

how to shift columns/rows of Example Set ?

User: "Gofman"
New Altair Community Member
Updated by Jocelyn
Hi,
I would like to shift the columns of a given data set right\left much like the "shift" operator of pandas for dataframes.
Is there any elegant way of doing so instead of renaming the columns names?

Thanks!

Find more posts tagged with

Sort by:
1 - 7 of 71
    User: "lionelderkrikor"
    New Altair Community Member
    Hi @Gofman,

    If I good understand what you want to do, you can use the Reorder Attributes operator.

    Hope this helps,

    Regards,

    Lionel
    User: "varunm1"
    New Altair Community Member
    Adding to @lionelderkrikor post, you can create dummy columns with null values (similar to shift) using generate attribute operator with a value NaN and then use reorder attributes to set these dummy columns at the start of data frame.


    User: "BalazsBaranyRM"
    New Altair Community Member
    Hi @Gofman,

    so you would copy the value from Col2 to Col3, then from Col1 to Col2, then fill Col1 with missings.

    Reorder Attributes would help you in sorting the columns for Loop Attributes.
    Then in Loop Attributes you would use Rename to the appropriate name, or Generate Attributes.

    Regards,
    Balázs
    User: "Gofman"
    New Altair Community Member
    OP
    Just like @BalazsBarany said, I want to shift all values of Col1 to Col2 and so on (Col 2 to Col 3..), thus "Reorder Attributes" does not help me much.

    Is there any other way of doing so without using loops? something more like a single operator?






    User: "varunm1"
    New Altair Community Member
    Updated by varunm1
    Hello @Gofman

    Yep, that is why I was talking about generate attribute before reorder. So, incase of pandas shift the columns are shifted places and a null column is added at the start. So, if you want to shift the colums by 2 periods, you can generate 2 columns with null values and reorder the attributes after that by placing these null columns infront of the original columns. If you want to rename the col names you can do that using rename operator as well. @BalazsBarany informed same but with loops

    I know this is not a direct way, but if you dont want to use loops, I guess this might work.

    Do you need a sample process?
    User: "BalazsBaranyRM"
    New Altair Community Member
    Accepted Answer
    No, there is no single operator.
    Also, you can always use the Python scripting operator if you already have a solution in Python.

    User: "sgenzer"
    Altair Employee
    hi @Gofman welcome to the community :smile: One key thing to understand about RapidMiner is that the ordering of the attributes in the Results view is purely aesthetics and can change all the time depending on what the last operator was. It is not like a database where the order remains constant. There are just not many situations where the order matters. Even the operator "Reorder Attributes" is basically a "vanity" operator to make things pretty when you see them.

    Scott