I am using styling for displaying a dataframe using Tabulator. The example is from here
Styling shows when I use
styled.show()
to display the page, but no styling is shown when
pn.Column(styled).show()
is used. Here is my complete code. I need to use pn.Column
so that I can show other content on the page.
import datetime as dt
import pandas as pd
import panel as pn
pn.extension('tabulator')
style_df = pd.DataFrame(np.random.randn(10, 5), columns=list('ABCDE'))
def color_negative_red(val):
"""
Takes a scalar and returns a string with
the css property `'color: red'` for negative
strings, black otherwise.
"""
color = 'red' if val < 0 else 'black'
return 'color: %s' % color
def highlight_max(s):
'''
highlight the maximum in a Series yellow.
'''
is_max = s == s.max()
return ['background-color: yellow' if v else '' for v in is_max]
styled = pn.widgets.Tabulator(style_df, page_size=5)
styled.style.applymap(color_negative_red).apply(highlight_max)
pn.Column(styled).show()
How do I make my styled
Tabulator show style when shown along with other components?