# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [Root]
#     language: python
#     name: Python [Root]
# ---

# # Test Network Updating when loading new data

import numpy as np
import pandas as pd
from clustergrammer_widget import *

# ## Define DataFrame

# +
# generate random matrix
num_rows = 500
num_cols = 10
np.random.seed(seed=100)
mat = np.random.rand(num_rows, num_cols)

# make row and col labels
rows = range(num_rows)
cols = range(num_cols)
rows = [str(i) for i in rows]
cols = [str(i) for i in cols]

# make dataframe 
df = pd.DataFrame(data=mat, columns=cols, index=rows)
# -

net = Network()
net.load_df(df)
net.make_clust()

clustergrammer_widget(network=net.widget())

net.filter_N_top('row', 10, 'sum')
small_df = net.export_df()

net.load_df(small_df)
net.make_clust()
clustergrammer_widget(network=net.widget())

# # Load data from File

net.load_file('txt/rc_two_cats.txt')
net.make_clust()
clustergrammer_widget(network=net.widget())

# Loading new data into `net` appears to be working correctly, will test in nbviewer.



StarcoderdataJupyterScriptsDedupFiltered