Data360 Analyze

 View Only
  • 1.  Python script inconsistency in Transform node

    Posted 05-11-2021 11:45

    Hi all,

    I am trying to do re.sub using Transform node (detailed in screenshot). The node runs, but the result is inconsistent. After some testing, I found out that the re.sub only considers the last value/rule from custom_rules object.

    If this were to work correctly, the result ("test"column) should say:

    • row 1: executive vice president
    • row 2: executive vice president chief technology officer
    • row 3: chief information
    • row 4: chief marketing
    • row 5: executive vice president chief information

    Am I doing something wrong? Any advice is appreciated.

    Bests



  • 2.  RE: Python script inconsistency in Transform node

    Posted 05-11-2021 11:52

    Adding screenshot attachment for better resolution

     

    Attached files

    Capture.PNG

     



  • 3.  RE: Python script inconsistency in Transform node

    Employee
    Posted 05-12-2021 03:32

    Your script is referencing the original input field value on every iteration of the for loop so the final value of the 'test' variable is the result from only the final iteration. Instead the script should define the initial value of the 'test' variable outside of the loop and then reference it in both the left-hand and right-hand sides of the expression.

     

    Which results in the following: