Skip to content

Instantly share code, notes, and snippets.

@SnowyPainter
Created January 29, 2023 10:24
Show Gist options
  • Save SnowyPainter/58d5ae1a58569dcdeee51ac7cb4de816 to your computer and use it in GitHub Desktop.
Save SnowyPainter/58d5ae1a58569dcdeee51ac7cb4de816 to your computer and use it in GitHub Desktop.
import pandas as pd
code_df = pd.read_csv('2021licode.csv')
stat_df = pd.read_csv('2021listat.csv')
code_df = code_df.drop(code_df.columns[[3,4,5]], axis=1)
code_df = code_df.iloc[3:-1]
def counted_tag(tag):
l = [x for x in stat_df[tag].tolist() if str(x) != 'nan']
return dict((x,l.count(x)) for x in set(l))
print("Q8A1 computer search")
print(counted_tag("Q8A1"))
print("Q8B1 phone search")
print(counted_tag("Q8B1"))
print("Q8A4 computer edu search")
print(counted_tag("Q8A4"))
print("Q8B4 phone edu search")
print(counted_tag("Q8B4"))
def compare_wt1():
#Q1A1 ~ Q8B4
wt1_df = stat_df[stat_df['WT'] == 1.00]
print(wt1_df.iloc[:,2:34].sum(axis=1).sum(axis=0)) #521
wtl1_df = stat_df[stat_df['WT'] < 1.00]
print(wtl1_df.iloc[:,2:34].sum(axis=1).sum(axis=0)) #1013
wto1_df = stat_df[stat_df['WT'] > 1.00]
print(wto1_df.iloc[:,2:34].sum(axis=1).sum(axis=0)) #666
compare_wt1()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment