Hi all,
I would like to do various operations on a table given a set of parameters, but want to avoid performing the operations more than once. What is the correct way to do this? I’m guessing there is an embarrassingly simple answer but I spent a couple hours going through docs/gallery examples and couldn’t figure it out.
Example:
class VolcanoPlots(param.Parameterized):
genes = param.Selector(objects=gene_list)
comparison = param.Selector(objects=comparison_list)
def view(self):
# Pandas operations
sub = des[des.label == self.comparison]
sub = sub[sub.gene_identifier.isin(gene_sets[self.genes])]
plot = sub.hvplot.scatter(...)
return plot
def table(self):
# Same pandas operations that I want to avoid doing a second time
sub = des[des.label == self.comparison]
sub = sub[sub.gene_identifier.isin(gene_sets[self.genes])]
return pn.pane.DataFrame(sub, width=1000, max_rows=25)
I want a final panel output like:
obj = VolcanoPlots()
panel = pn.Column(
pn.Row(obj.param, obj.view),
obj.table
)
I tried several things such as returning both in the same method, but then couldn’t figure out how to re-compose the panes as I wanted.