<jupyter_start><jupyter_text>Check Missing files<jupyter_code>party_names = list(set(df_zone_candidates.PartyName.values))
len(party_names)
for p in party_names:
    if not os.path.isfile('../creden/%s.csv.json' % p):
        print(p)
# print('\n'.join(party_names))<jupyter_output><empty_output><jupyter_text>Cross check numbers<jupyter_code>df_all_candidates = pd.concat([df_zone_candidates[attributes], df_pl_candidates[attributes]])
pols_in_party_dict = df_all_candidates[['PartyName', 'CandidateNo']].groupby('PartyName').count().to_dict()['CandidateNo']
data_files = glob.glob("/Users/heytitle/projects/politician-business/app/assets/data/*.json")
print("We have %d data files" % len(data_files))
for f in data_files:
    partyName = f.split('/')[-1].split('.')[0].strip()
    print('Verifying %s' % partyName)
    with open(f) as json_file:  
        data = json.load(json_file)
        totalPoliticians = len(data)
        totalFromCSVs = pols_in_party_dict[partyName]
        assert totalPoliticians == totalFromCSVs, \
            '%s: %d politicians but  %d in CSVs' % (partyName, totalPoliticians, totalFromCSVs)
len(df_pl_candidates[df_pl_candidates.PartyName == 'ประชาธิปัตย์'])<jupyter_output><empty_output><jupyter_text>Verify duplicated politicians<jupyter_code>data_files = glob.glob("/Users/heytitle/projects/politician-business/app/assets/data/*.json")
print("We have %d data files" % len(data_files))
for f in data_files:
    partyName = f.split('/')[-1].split('.')[0].strip()
#     print('Verifying %s' % partyName)
    with open(f) as json_file:  
        data = json.load(json_file)
        uniqPols = list(set(map(lambda x: x['name'], data)))
        totalUniqPoliticians = len(list(set(map(lambda x: x['name'], data))))
        totalPoliticians = len(data)
        if totalUniqPoliticians != totalPoliticians:
            print(data[:10])
#             print(uniqPols)
#             print(totalUniqPoliticians)
            print('We have dups politicians for %s, %d vs %d' % (partyName, totalUniqPoliticians, totalPoliticians) )
len(df_zone_candidates[df_zone_candidates['PartyName'] == 'ประชาธิปัตย์'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1505326540064845, 'fraction_numerical': 0.002779064381658175, 'mean_word_length': 4.714285714285714, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '126560', 'license': 'MIT', 'n_tokens_mistral': 785, 'n_tokens_neox': 765, 'n_words': 120, 'path': 'data-preparation/extract-all-candidates.ipynb', 'repo_name': 'heytitle/politics-and-business', 'size': '2159'}