Here is the existing code
import pandas as pd
import random
random_seed = 1234
random.seed(random_seed)
def create_rows(num=1):
output = [{ "ID":random.randint(1000,2000),
"CLASS":random.choice(['A', 'B', 'C']),
} for x in range(num)
]
return output
df = pd.DataFrame(create_rows(5000))
print (df.head())
How can I create the CLASS column in such a way that 'A' appears 50% of the time, while 'B' and 'C' each appears 25% of the time?
Aucun commentaire:
Enregistrer un commentaire