Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Python (2.7 preferably), using the dataframe below, how can I compute the fol

ID: 3766080 • Letter: I

Question

In Python (2.7 preferably), using the dataframe below, how can I compute the following:

1) if the value in column 6 is greater than 0 when Pheno==2, print True (apply this to columns 6,7, 8 and 9)

2) if the value in column 6 is 0 when Pheno==2, print True (apply this to columns 6,7, 8 and 9)

3)Print out results for each FID (455 and 320)

0 1 2 3 4 5 6 7 8 9 0 FID IID FatherID MotherID SEX PHENO 1 2 3 4 1 455 909 0 0 2 2 0 0 0 0 2 455 18734 910 909 2 2 0 0 0 0 3 320 3279 0 0 1 2 0 0 0 0 4 320 14938 3277 14933 2 2 0 0 0 0 5 320 14944 3278 14940 2 1 0 0 0 0

Explanation / Answer

import numpy as np
import sys
import pandas as pd

data = {0:pd.series(['FID',455.,455.,320.,320.,320.],index=[0,1,2,3,4,5]),
       1:pd.series(['IID',909.,18734.,3279.,14938.,14944.],index=[0,1,2,3,4,5]),
       2:pd.series(['FatherID',0.,910.,0.,3277.,3278.],index=[0,1,2,3,4,5]),
       3:pd.series(['MotherID',0.,909.,0.,14933.,14940.],index=[0,1,2,3,4,5]),
       4:pd.series(['SEX',2.,2.,1.,2.,2.],index=[0,1,2,3,4,5]),
       5:pd.series(['PHENO',2.,2.,2.,2.,1.],index=[0,1,2,3,4,5]),
       6:pd.series([1.,0.,0.,0.,0.,0.],index=[0,1,2,3,4,5]),
       7:pd.series([2.,0.,0.,0.,0.,0.],index=[0,1,2,3,4,5]),
       8:pd.series([3.,0.,0.,0.,0.,0.],index=[0,1,2,3,4,5]),
       9:pd.series([4.,0.,0.,0.,0.,0.],index=[0,1,2,3,4,5]),
}
output = pd.DataFrame(data)
print output

for count in range(0,5):
   if np.where(output.index==count) and np.where(output.series(6))>0 and np.where(output.series('PHENO'))==2:
       print("Value in Column 6 is >0 and PHENO=2")
       return True;
   elif np.where(output.index==count) and np.where(output.series(6))=0 and np.where(output.series('PHENO'))==2:
       print("Value in Column 6 is =0 and PHENO=2")
       return True;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote