Creating two lists from one randomly

后端 未结 1 829
逝去的感伤
逝去的感伤 2021-01-13 22:37

I\'m using pandas to import a lot of data from a CSV file, and once read I format it to contain only numerical data. This then returns a list within a list. Each list then c

1条回答
  •  天涯浪人
    2021-01-13 23:08

    You can use random.shuffle and split list after that. For toy example:

    import random
    data = range(1, 11)
    
    random.shuffle(data)
    
    training = data[:5]
    testing = data[5:]
    

    To get more information, read the docs.

    0 讨论(0)
提交回复
热议问题