Last active
September 2, 2024 18:19
-
-
Save tashrifbillah/d53758c3359ef2e03c852d42728e5055 to your computer and use it in GitHub Desktop.
Explore values in FIGS form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pandas as pd | |
from glob import glob | |
new_vars="chrfigs_mother_ddx,chrfigs_mother_ddx_agree,chrfigs_mother_ddx_why,chrfigs_mother_mdx,chrfigs_mother_mdx_agree,\ | |
chrfigs_mother_mdx_why,chrfigs_mother_pdx,chrfigs_mother_pdx_agree,chrfigs_mother_pdx_why,chrfigs_mother_napdx,\ | |
chrfigs_mother_napdx_agree,chrfigs_mother_napdx_why,chrfigs_mother_apdx,chrfigs_mother_apdx_agree,chrfigs_mother_apdx_why,\ | |
chrfigs_father_ddx,chrfigs_father_ddx_agree,chrfigs_father_ddx_why,chrfigs_father_mdx,chrfigs_father_mdx_agree,\ | |
chrfigs_father_mdx_why,chrfigs_father_pdx,chrfigs_father_pdx_agree,chrfigs_father_pdx_why,chrfigs_father_napdx,\ | |
chrfigs_father_napdx_agree,chrfigs_father_napdx_why,chrfigs_father_apdx,chrfigs_father_apdx_agree,chrfigs_father_apdx_why".split(',') | |
files=glob('Prescient??/raw/*/surveys/*_family_interview_for_genetic_studies_figs.csv') | |
unique={} | |
for v in new_vars: | |
unique[v]=[] | |
for file in files: | |
df=pd.read_csv(file,dtype=str) | |
for v in new_vars: | |
if 'why' in v: | |
continue | |
else: | |
if v not in df: | |
continue | |
else: | |
v2=df.loc[0,v] | |
if not unique[v]: | |
unique[v]=[v2] | |
else: | |
if v2 not in unique[v]: | |
unique[v].append(v2) | |
unique |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment