<jupyter_start><jupyter_text>Combine tables  Category -> Binary<jupyter_code>for col in df_plugin_usage.columns[1:]:
    df_plugin_usage[col].values[df_plugin_usage[col] > 1] = 1
df_plugin_usage<jupyter_output><empty_output><jupyter_text>Change name<jupyter_code>ori_cols = df_plugin_usage.columns[1:]
ori_cols
def add_prefix(df, prefix):
    new_cols = {c: f"{prefix}_{c}" for c in ori_cols}
#     print(new_cols)
    df_rename = df.rename(columns=new_cols)
    return df_rename
# add_prefix to plugin_usage
df_plugin_usage_rename = add_prefix(df_plugin_usage, "u")
df_plugin_usage_rename
# add_prefix to plugin_declaration
df_plugin_declaration_rename = add_prefix(df_plugin_declaration, "d")
df_plugin_declaration_rename
# add_prefix to plugin_permission
df_plugin_permission_declaration_rename = add_prefix(df_plugin_permission_declaration, "p")
df_plugin_permission_declaration_rename<jupyter_output><empty_output><jupyter_text>Combine tables<jupyter_code>from functools import reduce
dfs = [df_plugin_usage_rename, df_plugin_declaration_rename, df_plugin_permission_declaration_rename, df_permission]
df_plugin = reduce(lambda x, y: pd.merge(x, y, on="apk_name", how="outer"), dfs)
df_plugin
df_plugin.info()
# Convert string to int
from collections import Counter
plugins_cols = df_plugin.columns[1:]
for col in plugins_cols:
    df_plugin[col] = df_plugin[col].astype(int)
    # print exception that contains more than 2 values
    values = Counter(df_plugin[col])
    if len(values) > 2:
        print(values, col)
df_plugin
df_plugin.to_csv("../db/cdv/cordova_FeatureSet.csv", index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09699201964395335, 'fraction_numerical': 0.004297114794352364, 'mean_word_length': 7.763440860215054, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, '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': '616364', 'license': 'Apache-2.0', 'n_tokens_mistral': 581, 'n_tokens_neox': 580, 'n_words': 104, 'path': 'apk_analysis/data_analysis/Feature Set.ipynb', 'repo_name': 'AllenSun7/Android-Security-Analysis', 'size': '1629'}