Want to create column with random values from list

Options
pphanireddy007
pphanireddy007 Registered Posts: 3

Hi All,

I want to create column with random values from list.

List values = test1,test2,test3 etc

I want to insert above values randomly.

Example-

Column1(Coming from DB) Random values

1 Test1

2 Test3

3 Test1

4 Test2

5 Test3


Operating system used: windows

Best Answer

  • JuanE
    JuanE Dataiker, Registered Posts: 45 Dataiker
    edited July 17 Answer ✓
    Options

    You can do this in many ways. One that I think is neat is to use a Python processor in a Prepare step:

    Capture.PNG

    This is the sample code, modify it according to your needs as you see fit:

    import random
    def process(row):
        my_list = ["test1", "test2", "test3"]
        return random.choice(my_list)

Setup Info
    Tags
      Help me…