mercredi 15 juillet 2020

How to pick from multiple lists randomly to fill DFcolumns

I want to fill a Pandas DataFrame with 3 columns and 20 rows based on random values from the 3 lists below. I cant quite figure out what I am doing wrong. Any suggestions?

import random
import pandas as pd 
import numpy as np


tests= ['TestA', 'TestB', 'TestC', 'TestD']
projects = ['AK', 'AA', 'JH', 'WM']
number = [10, 100, 200, 1000, 2000]

df = pd.DataFrame()

for i in range(1,21):
    df = df.append(
    {'TEST': random.choice(tests),
    'PROJ': random.choice(projects),
    'NUMBER': random.choice(number)})



Aucun commentaire:

Enregistrer un commentaire