I have 1000 rows * 100 columns dataset. wanted to generate Random number with the help of these data. specifically for a some columns. say 20 columns.
have performed - random.randrange(min(dataset["col_1"]),max(dataset["col_1"])).
since I have float data, randrange functions gave an error. So tried with random.uniform(). It works, but I have many columns to do the same job. So wanted to create a function using a loop.
What I wanted to have is n variables with the random values generated. Wanted to save the numbers along with the name for each.
How to create a function with a loop? so that, whenever I pass a list of columns in the dataset, It should give me a value for each column.
sample data
Cat-1 old-1 New-1 Old-2 New-2 W1 W2
RICE 0.05 0.48 0.47 10775 9087
RICE 0.26 0.05 0.45 0.24 15486 16335
RICE 0.34 0.05 0.38 0.23 9774 8384
RICE 0.30 0.05 0.42 0.23 7292 6390
RICE 0.32 0.05 0.40 0.23 7103 6275
RICE 0.29 0.05 0.39 0.27 6712 6095
RICE 0.26 0.05 0.40 0.29 6358 5774
RICE 0.25 0.05 0.41 0.29 6005 5453
RICE 0.34 0.05 0.61 5652 5132
expected output:
old-1 0.31
New-1 0.05
Old-2 0.43
New-2 0.24
Aucun commentaire:
Enregistrer un commentaire