<jupyter_start><jupyter_text>Generate categories from grouping<jupyter_code>import pandas as pd
import numpy as np
from clustergrammer_widget import *
net = Network()
net.load_file('txt/rc_two_cats.txt')
dat_names = net.dat['node_info']['row']['full_names']
df = net.export_df()
df_names = df.index.tolist()
# nodes are in the same order in dat and df
for i in range(len(dat_names)):
    if dat_names[i] != df_names[i]:
        print('no match')<jupyter_output><empty_output><jupyter_text>gather group information at a particular level and add to the row tuple names. Then load this into net and visualize There is no group key before clustering<jupyter_code>net.dat['node_info']['row'].keys()<jupyter_output><empty_output><jupyter_text>Clustering adds new keys to the node_info object<jupyter_code>net.make_clust()
net.dat['node_info']['row'].keys()<jupyter_output><empty_output><jupyter_text>Gather row group information from level 5 of the dendrogram, the default level. Higher levels are more coarse grained.<jupyter_code>row_groups = net.dat['node_info']['row']['group']['05']
rows = df.index.tolist()
new_rows = []
for i in range(len(rows)):
    inst_row = rows[i]
    group_cat = 'group-' + str(row_groups[i])
    inst_row = inst_row + (group_cat,)
    new_rows.append(inst_row)
new_rows
df.index = new_rows
net.load_df(df)
net.make_clust()
clustergrammer_widget(network=net.widget())<jupyter_output><empty_output><jupyter_text>The new row cats match the dendrogram groups. I'll add this function as a method to net.  Check method<jupyter_code>net.dendro_cats('row', 5)
net.make_clust()
net.dendro_cats('row', 2)
clustergrammer_widget(network=net.widget())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.125812167749557, 'fraction_numerical': 0.0029533372711163615, 'mean_word_length': 6.806451612903226, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '54161', 'license': 'MIT', 'n_tokens_mistral': 604, 'n_tokens_neox': 584, 'n_words': 141, 'path': 'Add dendro-group cats.ipynb', 'repo_name': 'scvannost/clustergrammer-py', 'size': '1693'}