<jupyter_start><jupyter_text>Count number of available examples<jupyter_code>import os

import pandas as pd
df = pd.read_csv('data.csv')<jupyter_output><empty_output><jupyter_text>Count number of JSON files<jupyter_code>dir_abs_path = 'data'
file_names = []
for root, dirs, files in os.walk(dir_abs_path):
    for name in files:
        if name.endswith('.json'):
            file_names.append(os.path.splitext(name)[0])
len(file_names)<jupyter_output><empty_output><jupyter_text>Custom function<jupyter_code>def is_available(hash):
    if hash in file_names:
        return True
    else:
        return False<jupyter_output><empty_output><jupyter_text>Add `availability` column<jupyter_code>df['availability'] = df.hash.apply(is_available)
df.availability.sum()<jupyter_output><empty_output><jupyter_text>Filter by `availability` column<jupyter_code>dff = df[df.availability==True]<jupyter_output><empty_output><jupyter_text>Save to pickle<jupyter_code>dff.to_pickle('available_20200407.pkl')<jupyter_output><empty_output><jupyter_text>Test pickle file<jupyter_code>pd.read_pickle('available_20200407.pkl')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1195079086115993, 'fraction_numerical': 0.014938488576449912, 'mean_word_length': 7.968503937007874, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '311326', 'license': 'Unlicense', 'n_tokens_mistral': 438, 'n_tokens_neox': 419, 'n_words': 55, 'path': 'jupyter_notebooks/0001_available_examples.ipynb', 'repo_name': 'korniichuk/phd', 'size': '1138'}