import param import panel as pn pn.extension(sizing_mode="stretch_width", notifications=True) import pickle import pandas as pd css = ['https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css', # Below: Needed for export buttons 'https://cdn.datatables.net/buttons/1.7.0/css/buttons.dataTables.min.css' ] js = { '$': 'https://code.jquery.com/jquery-3.5.1.js', 'DataTable': 'https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js', # Below: Needed for export buttons 'buttons': 'https://cdn.datatables.net/buttons/1.7.0/js/dataTables.buttons.min.js', 'jszip': 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js', 'pdfmake': 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js', 'vfsfonts': 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js', 'html5buttons': 'https://cdn.datatables.net/buttons/1.7.0/js/buttons.html5.min.js', } pn.extension(css_files=css, js_files=js) script = """ """ # html = autompg.to_html(classes=['example', 'panel-df']) import pandas as pd class ReactiveTables(param.Parameterized): name_ = param.String('Asian') record_start_index = param.Integer(1) record_stop_index = param.Integer(200) old_data = None @param.depends('name_', 'record_start_index', 'record_stop_index') def data(self): print('new name', self.name_) if len(self.name_) > 0: if ord(self.name_[0]) in list(range(48, 57)): file_name = 'num_dict.pkl' elif ord(self.name_[0]) in list(range(97, 122)) + list(range(65, 90)): file_name = f'{ord(self.name_[0])}_dict.pkl' else: file_name = 'other_dict.pkl' print(f'all_secret_langauge_by_fist/{file_name}') datas = pickle.load(open(f'all_secret_langauge_by_fist/{file_name}', 'rb')) if self.name_ in datas.keys(): self.old_data = pd.DataFrame(datas[self.name_]) return self.old_data, datas @param.depends('name_') def summary(self): return self.data()[0].describe() @param.depends('name_', 'record_start_index', 'record_stop_index') def table_ours(self): data = self.data()[0] return pn.pane.HTML(data[max(0, self.record_start_index): min(min(self.record_stop_index + 1, self.record_start_index + 2001), len(data))].to_html( classes=['example', 'panel-df']) + script, sizing_mode='stretch_width') @param.depends('name_', 'record_start_index', 'record_stop_index') def notification(self): datas = self.data()[1] if datas: if self.name_ in datas.keys(): return pn.pane.HTML(f'