How to generate random float numbers for each SNP using Python

57 Views Asked by At

I'm dealing with GWAS data, here I have a column name SNP_Id which is of 2 Million rows and I need to generate random float values for each SNP_Id!. How to do so?

Input_Data:

SNP_Id
200610-10
200610-108
200610-109
200610-116
200610-118
200610-125
.
.

So on like this, I have 2M rows

Desired Output:

200610-10, 8.9
200610-108, 90.9
200610-109, 76.9
200610-116, 728.9
200610-118, 646.9
200610-125, 766.9
.
.

I've tried this:

with open('SNP.csv') as f:
    reader = csv.reader(f)
    for row in reader:
        snp_list = np.random.random(0, len(SNP.csv))

But no use, enlighten me what I'm doing wrong?

1

There are 1 best solutions below

0
On

You can use numpy where df1 is your dataframe containing GWAS snp data as given below,

   import numpy as np
   df1['randNumCol'] = np.random.uniform(0,len(df1), size=len(df1))

Taken from 1.