Home Forums Main Forums Python Forum How to create a unique sequence number for each row?

  • How to create a unique sequence number for each row?

     Tundra.L updated 6 months, 2 weeks ago 4 Members · 6 Posts
  • norahx

    Member
    November 26, 2020 at 6:55 am
    Up
    0
    Down

    You mean calculate the sum of each row to generate a new column?

    • Justin

      Administrator
      November 26, 2020 at 4:22 pm
      Up
      0
      Down

      Not a sum, just a sequence ID. In SAS, we can use the SUM statement to create a sequence ID or a cumulative sum.

  • Tundra.L

    Member
    November 26, 2020 at 10:41 am
    Up
    0
    Down

    If this is what you mean:

    normally I used following methods to assign labels for segments

    1. customer function to define the segment, the labels will be numeric data

    2.cut() or qcut (), the labels will be category data

    3. ceil() for special situation, the labels will be numeric data

    • Justin

      Administrator
      November 26, 2020 at 4:23 pm
      Up
      0
      Down

      It’s too complicated, we have a better way.

      • Tundra.L

        Member
        November 26, 2020 at 4:32 pm
        Up
        0
        Down

        can you show us please?

  • Datura

    Member
    October 22, 2020 at 10:22 am
    Up
    0
    Down

    In real work, we often need to have a unique sequence ID for each row, or for each row in each group, such as 1, 2, 3……………… N. For example, for our RFM project, we need such a Sequence ID for segmentation.

    It is very easy to do it in SAS by using the SUM statement, however, not easy in R and Python. Can you work out the code for creating such a sequence ID for each row, and for each row of each group? How many different methods you can figure out?

    • This discussion was modified 7 months, 3 weeks ago by  Datura.

Log in to reply.

Original Post
0 of 0 posts June 2018
Now