<jupyter_start><jupyter_text>The ``Tabulator`` widget allows displaying and editing a pandas DataFrame. The `Tabulator` is a largely backward compatible replacement for the [`DataFrame`](./DataFrame.ipynb) widget and will eventually replace it. It is built on the [Tabulator](http://tabulator.info/) library, which provides for a wide range of features.For more information about listening to widget events and laying out widgets refer to the [widgets user guide](../../user_guide/Widgets.ipynb). Alternatively you can learn how to build GUIs by declaring parameters independently of any specific widgets in the [param user guide](../../user_guide/Param.ipynb). To express interactivity entirely using Javascript without the need for a Python server take a look at the [links user guide](../../user_guide/Param.ipynb). Parameters:For layout and styling related parameters see the [customization user guide](../../user_guide/Customization.ipynb). Core* **``aggregators``** (``dict``): A dictionary mapping from index name to an aggregator to be used for `hierarchical` multi-indexes (valid aggregators include 'min', 'max', 'mean' and 'sum'). If separate aggregators for different columns are required the dictionary may be nested as `{index_name: {column_name: aggregator}}`* **``configuration``** (``dict``): A dictionary mapping used to specify tabulator options not explicitly exposed by panel.* **``editors``** (``dict``):  A dictionary mapping from column name to a bokeh `CellEditor` instance or tabulator editor specification.* **``embed_content``** (``boolean``): Whether to embed the `row_content` or to dynamically fetch it when a row is expanded.* **``expanded``** (``list``): The currently expanded rows as a list of integer indexes.* **``filters``** (``list``): A list of client-side filter definitions that are applied to the table.* **``formatters``** (``dict``): A dictionary mapping from column name to a bokeh `CellFormatter` instance or tabulator formatter specification.* **``groupby``** (`list`): Groups rows in the table by one or more columns.* **``header_align``** (``dict`` or ``str``): A mapping from column name to header alignment or a fixed header alignment, which should be one of `'left'`, `'center'`, `'right'`.* **``header_filters``** (``boolean``/``dict``): A boolean enabling filters in the column headers or a dictionary providing filter definitions for specific columns.* **``hierarchical``** (boolean, default=False): Whether to render multi-indexes as hierarchical index (note hierarchical must be enabled during instantiation and cannot be modified later)* **``hidden_columns``** (`list`): List of columns to hide.* **``layout``** (``str``, `default='fit_data_table'`): Describes the column layout mode with one of the following options `'fit_columns'`, `'fit_data'`, `'fit_data_stretch'`, `'fit_data_fill'`, `'fit_data_table'`. * **``frozen_columns``** (`list`): List of columns to freeze, preventing them from scrolling out of frame. Column can be specified by name or index.* **``frozen_rows``**: (`list`): List of rows to freeze, preventing them from scrolling out of frame. Rows can be specified by positive or negative index.* **``page``** (``int``, `default=1`): Current page, if pagination is enabled.* **``page_size``** (``int``, `default=20`): Number of rows on each page, if pagination is enabled.* **``pagination``** (`str`, `default=None`):  Set to `'local` or `'remote'` to enable pagination; by default pagination is disabled with the value set to `None`.* **``row_content``** (``callable``): A function that receives the expanded row as input and should return a Panel object to render into the expanded region below the row.* **``row_height``** (``int``, `default=30`):  The height of each table row.* **``selection``** (``list``): The currently selected rows as a list of integer indexes.* **``selectable``** (`boolean` or `str` or `int`, `default=True`): Defines the selection mode:  * `True`      Selects rows on click. To select multiple use Ctrl-select, to select a range use Shift-select  * `False`      Disables selection  * `'checkbox'`      Adds a column of checkboxes to toggle selections  * `'checkbox-single'`      Same as 'checkbox' but header does not alllow select/deselect all  * `'toggle'`      Selection toggles when clicked  * `int`      The maximum number of selectable rows.* **``selectable_rows``** (`callable`): A function that should return a list of integer indexes given a DataFrame indicating which rows may be selected.* **``show_index``** (``boolean``, `default=True`): Whether to show the index column.* **``text_align``** (``dict`` or ``str``): A mapping from column name to alignment or a fixed column alignment, which should be one of `'left'`, `'center'`, `'right'`.* **`theme`** (``str``, `default='simple'`): The CSS theme to apply (note that changing the theme will restyle all tables on the page), which should be one of `'default'`, `'site'`, `'simple'`, `'midnight'`, `'modern'`, `'bootstrap'`, `'bootstrap4'`, `'materialize'`, `'bulma'`, `'semantic-ui'`, or `'fast'`.* **``titles``** (``dict``): A mapping from column name to a title to override the name with.* **``value``** (``pd.DataFrame``): The pandas DataFrame to display and edit* **``widths``** (``dict``): A dictionary mapping from column name to column width in the rendered table. Display* **``disabled``** (``boolean``): Whether the widget is editable* **``name``** (``str``): The title of the widget Properties* **``current_view``** (``DataFrame``): The current view of the table that is displayed, i.e. after sorting and filtering are applied* **``selected_dataframe``** (``DataFrame``): A DataFrame reflecting the currently selected rows.___ The ``Tabulator`` widget renders a DataFrame using an interactive grid, which allows directly editing the contents of the dataframe in place, with any changes being synced with Python. The `Tabulator` will usually determine the appropriate formatter appropriately based on the type of the data:<jupyter_code>df = pd.DataFrame({
    'int': [1, 2, 3],
    'float': [3.14, 6.28, 9.42],
    'str': ['A', 'B', 'C'],
    'bool': [True, False, True],
    'date': [dt.date(2019, 1, 1), dt.date(2020, 1, 1), dt.date(2020, 1, 10)],
    'datetime': [dt.datetime(2019, 1, 1, 10), dt.datetime(2020, 1, 1, 12), dt.datetime(2020, 1, 10, 13)]
}, index=[1, 2, 3])

df_widget = pn.widgets.Tabulator(df)
df_widget<jupyter_output><empty_output><jupyter_text>FormattersBy default the widget will pick bokeh ``CellFormatter`` and ``CellEditor`` types appropriate to the dtype of the column. These may be overriden by explicit dictionaries mapping from the column name to the editor or formatter instance. For example below we create a ``SelectEditor`` instance to pick from four options in the ``str`` column and a ``NumberFormatter`` to customize the formatting of the float values:<jupyter_code>from bokeh.models.widgets.tables import NumberFormatter, BooleanFormatter

bokeh_formatters = {
    'float': NumberFormatter(format='0.00000'),
    'bool': BooleanFormatter(),
}

pn.widgets.Tabulator(df, formatters=bokeh_formatters)<jupyter_output><empty_output><jupyter_text>The list of valid Bokeh formatters includes:    * [BooleanFormatter](https://docs.bokeh.org/en/latest/docs/reference/models/widgets.tables.htmlbokeh.models.widgets.tables.BooleanFormatter)* [DateFormatter](https://docs.bokeh.org/en/latest/docs/reference/models/widgets.tables.htmlbokeh.models.widgets.tables.DateFormatter)* [NumberFormatter](https://docs.bokeh.org/en/latest/docs/reference/models/widgets.tables.htmlbokeh.models.widgets.tables.NumberFormatter)* [HTMLTemplateFormatter](https://docs.bokeh.org/en/latest/docs/reference/models/widgets.tables.htmlbokeh.models.widgets.tables.HTMLTemplateFormatter)* [StringFormatter](https://docs.bokeh.org/en/latest/docs/reference/models/widgets.tables.htmlbokeh.models.widgets.tables.StringFormatter)* [ScientificFormatter](https://docs.bokeh.org/en/latest/docs/reference/models/widgets.tables.htmlbokeh.models.widgets.tables.ScientificFormatter)However in addition to the formatters exposed by Bokeh it is also possible to provide valid formatters built into the Tabulator library. These may be defined either as a string or as a dictionary declaring the 'type' and other arguments, which are passed to Tabulator as the `formatterParams`:<jupyter_code>tabulator_formatters = {
    'float': {'type': 'progress', 'max': 10},
    'bool': {'type': 'tickCross'}
}

pn.widgets.Tabulator(df, formatters=tabulator_formatters)<jupyter_output><empty_output><jupyter_text>The list of valid Tabulator formatters can be found in the [Tabulator documentation](http://tabulator.info/docs/4.9/formatformat-builtin). EditorsJust like the formatters, the `Tabulator` will natively understand the Bokeh `Editor` types. However, in the background it will replace most of them with equivalent editors natively supported by the tabulator library:<jupyter_code>from bokeh.models.widgets.tables import CheckboxEditor, NumberEditor, SelectEditor, DateEditor, TimeEditor

bokeh_editors = {
    'float': NumberEditor(),
    'bool': CheckboxEditor(),
    'str': SelectEditor(options=['A', 'B', 'C', 'D']),
}

pn.widgets.Tabulator(df[['float', 'bool', 'str']], editors=bokeh_editors)<jupyter_output><empty_output><jupyter_text>Therefore it is often preferable to use one of the [Tabulator editors](http://tabulator.info/docs/5.0/editedit) directly. Note that in addition to the standard Tabulator editors the Tabulator widget also supports `'date'` and `'datetime'` editors:<jupyter_code>from bokeh.models.widgets.tables import CheckboxEditor, NumberEditor, SelectEditor

bokeh_editors = {
    'float': {'type': 'number', 'max': 10, 'step': 0.1},
    'bool': {'type': 'tickCross', 'tristate': True, 'indeterminateValue': None},
    'str': {'type': 'autocomplete', 'values': True},
    'date': 'date',
    'datetime': 'datetime'
}

edit_table = pn.widgets.Tabulator(df, editors=bokeh_editors)

edit_table<jupyter_output><empty_output><jupyter_text>When editing a cell the data stored on the `Tabulator.value` is updated and you can listen to any changes using the usual `.param.watch(callback, 'value')` mechanism. However if you need to know precisely which cell was changed you may also attach an `on_edit` callback which will be passed a `TableEditEvent` containing the:- `column`: Name of the edited column- `row`: Integer index of the edited row- `value`: The updated value<jupyter_code>edit_table.on_edit(lambda e: print(e.column, e.row, e.value))<jupyter_output><empty_output><jupyter_text>Column layoutsBy default the DataFrame widget will adjust the sizes of both the columns and the table based on the contents, reflecting the default value of the parameter: `layout="fit_data_table"`. Alternative modes allow manually specifying the widths of the columns, giving each column equal widths, or adjusting just the size of the columns. Manual column widthsTo manually adjust column widths provide explicit `widths` for each of the columns:<jupyter_code>custom_df = pd._testing.makeMixedDataFrame()

pn.widgets.Tabulator(custom_df, widths={'index': 70, 'A': 50, 'B': 50, 'C': 70, 'D': 130})<jupyter_output><empty_output><jupyter_text>You can also declare a single width for all columns this way:<jupyter_code>pn.widgets.Tabulator(custom_df, widths=130)<jupyter_output><empty_output><jupyter_text>Autosize columnsTo automatically adjust the columns dependending on their content set `layout='fit_data'`:<jupyter_code>pn.widgets.Tabulator(custom_df, layout='fit_data', width=400)<jupyter_output><empty_output><jupyter_text>To ensure that the table fits all the data but also stretches to fill all the available space, set `layout='fit_data_stretch'`:<jupyter_code>pn.widgets.Tabulator(custom_df, layout='fit_data_stretch', width=400)<jupyter_output><empty_output><jupyter_text>The `'fit_data_fill'` option on the other hand won't stretch the last column but still fill the space:<jupyter_code>pn.widgets.Tabulator(custom_df, layout='fit_data_fill', width=400)<jupyter_output><empty_output><jupyter_text>Perhaps the most useful of these options is `layout='fit_data_table'` (and therefore the default) since this will automatically size both the columns and the table:<jupyter_code>pn.widgets.Tabulator(custom_df, layout='fit_data_table')<jupyter_output><empty_output><jupyter_text>Equal sizeThe simplest option is simply to allocate each column equal amount of size:<jupyter_code>pn.widgets.Tabulator(custom_df, layout='fit_columns', width=650)<jupyter_output><empty_output><jupyter_text>AlignmentThe content of a column or its header can be horizontally aligned with `text_align` and `header_align`. These two parameters accept either a string that globally defines the alignment or a dictionnary that declares which particular columns are meant to be aligned and how.<jupyter_code>pn.widgets.Tabulator(df, header_align='center', text_align={'str': 'right', 'bool': 'center'}, widths=200)<jupyter_output><empty_output><jupyter_text>StylingThe ability to style the contents of a table based on its content and other considerations is very important. Thankfully pandas provides a powerful [styling API](https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html), which can be used in conjunction with the `Tabulator` widget. Specifically the `Tabulator` widget exposes a `.style` attribute just like a `pandas.DataFrame` which lets the user apply custom styling using methods like `.apply` and `.applymap`. For a detailed guide to styling see the [Pandas documentation](https://pandas.pydata.org/pandas-docs/stable/user_guide/style.html).Here we will demonstrate with a simple example, starting with a basic table:<jupyter_code>style_df = pd.DataFrame(np.random.randn(10, 5), columns=list('ABCDE'))
styled = pn.widgets.Tabulator(style_df)<jupyter_output><empty_output><jupyter_text>Next we define two functions which apply styling cell-wise (`color_negative_red`) and column-wise (`highlight_max`), which we then apply to the `Tabulator` using the `.style` API and then display the `styled` table:<jupyter_code>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.style.applymap(color_negative_red).apply(highlight_max)

styled<jupyter_output><empty_output><jupyter_text>ThemingThe Tabulator library ships with a number of themes, which are defined as CSS stylesheets. For that reason changing the theme on one table will affect all Tables on the page and it will usually be preferable to see the theme once at the class level like this:```pythonpn.widgets.Tabulator.theme = 'default'```For a full list of themes see the [Tabulator documentation](http://tabulator.info/docs/4.9/theme), however the default themes include:- `'simple'`- `'default'`- `'midnight'`- `'site'`- `'modern'`- `'bootstrap'`- `'bootstrap4'`- `'materialize'`- `'semantic-ui'`- `'bulma'`  SelectionThe `selection` parameter controls which rows in the table are selected and can be set from Python and updated by selecting rows on the frontend:<jupyter_code>sel_df = pd.DataFrame(np.random.randn(10, 5), columns=list('ABCDE'))

select_table = pn.widgets.Tabulator(sel_df, selection=[0, 3, 7])
select_table<jupyter_output><empty_output><jupyter_text>Once initialized, the ``selection`` parameter will return the integer indexes of the selected rows, while the ``selected_dataframe`` property will return a new DataFrame containing just the selected rows:<jupyter_code>select_table.selection = [1, 4, 9]

select_table.selected_dataframe<jupyter_output><empty_output><jupyter_text>The `selectable` parameter declares how the selections work. - `True`: Selects rows on click. To select multiple use Ctrl-select, to select a range use Shift-select- `False`: Disables selection- `'checkbox'`: Adds a column of checkboxes to toggle selections- `'checkbox-single'`: Same as `'checkbox'` but disables (de)select-all in the header- `'toggle'`: Selection toggles when clicked- Any positive `int`: A number that sets the maximum number of selectable rows<jupyter_code>pn.widgets.Tabulator(sel_df, selection=[0, 3, 7], selectable='checkbox')<jupyter_output><empty_output><jupyter_text>Additionally we can also disable selection for specific rows by providing a `selectable_rows` function. The function must accept a DataFrame and return a list of integer indexes indicating which rows are selectable, e.g. here we disable selection for every second row:<jupyter_code>pn.widgets.Tabulator(sel_df, selectable_rows=lambda df: list(range(0, len(df), 2)))<jupyter_output><empty_output><jupyter_text>Freezing rows and columnsSometimes your table will be larger than can be displayed in a single viewport, in which case scroll bars will be enabled. In such cases, you might want to make sure that certain information is always visible. This is where the `frozen_columns` and `frozen_rows` options come in. Frozen columnsWhen you have a large number of columns and can't fit them all on the screen you might still want to make sure that certain columns do not scroll out of view. The `frozen_columns` option makes this possible by specifying a list of columns that should be frozen, e.g. `frozen_columns=['index']` will freeze the index column:<jupyter_code>wide_df = pd._testing.makeCustomDataframe(10, 10, r_idx_names=['index'])

pn.widgets.Tabulator(wide_df, frozen_columns=['index'], width=400)<jupyter_output><empty_output><jupyter_text>Frozen rowsAnother common scenario is when you have certain rows with special meaning, e.g. aggregates that summarize the information in the rest of the table. In this case you may want to freeze those rows so they do not scroll out of view. You can achieve this by setting a list of `frozen_rows` by integer index (which can be positive or negative, where negative values are relative to the end of the table):<jupyter_code>date_df = pd._testing.makeTimeDataFrame().iloc[:10]
agg_df = pd.concat([date_df, date_df.median().to_frame('Median').T, date_df.mean().to_frame('Mean').T])
agg_df.index= agg_df.index.map(str)

pn.widgets.Tabulator(agg_df, frozen_rows=[-2, -1], width=400)<jupyter_output><empty_output><jupyter_text>Row contentsA table can only display so much information without becoming difficult to scan. We may want to render additional information to a table row to provide additional context. To make this possible you can provide a `row_content` function which is given the table row as an argument and should return a panel object that will be rendered into an expanding region below the row. By default the contents are fetched dynamically whenever a row is expanded, however using the `embed_content` parameter we can embed all the content.Below we create a periodic table of elements where the Wikipedia page for each element will be rendered into the expanded region:<jupyter_code>from bokeh.sampledata.periodic_table import elements

periodic_df = elements[['atomic number', 'name', 'atomic mass', 'metal', 'year discovered']].set_index('atomic number')

content_fn = lambda row: pn.pane.HTML(
    f'<iframe src="http://en.wikipedia.org/wiki/{row["name"]}?printable=yes" width="100%" height="300px"></iframe>',
    sizing_mode='stretch_width'
)

periodic_table = pn.widgets.Tabulator(
    periodic_df, height=500, layout='fit_columns', sizing_mode='stretch_width',
    row_content=content_fn, embed_content=True
)

periodic_table<jupyter_output><empty_output><jupyter_text>The currently expanded rows can be accessed (and set) on the `expanded` parameter:<jupyter_code>periodic_table.expanded<jupyter_output><empty_output><jupyter_text>GroupingAnother useful option is the ability to group specific rows together, which can be achieved using `groups` parameter. The `groups` parameter should be composed of a dictionary mapping from the group titles to the column names:<jupyter_code>pn.widgets.Tabulator(date_df, groups={'Group 1': ['A', 'B'], 'Group 2': ['C', 'D']})<jupyter_output><empty_output><jupyter_text>GroupbyIn addition to grouping columns we can also group rows by the values along one or more columns:<jupyter_code>from bokeh.sampledata.autompg import autompg

pn.widgets.Tabulator(autompg, groupby=['yr', 'origin'], height=240)<jupyter_output><empty_output><jupyter_text>Hierarchical Multi-indexThe `Tabulator` widget can also render a hierarchical multi-index and aggregate over specific categories. If a DataFrame with a hierarchical multi-index is supplied and the `hierarchical` is enabled the widget will group data by the categories in the order they are defined in. Additionally for each group in the multi-index an aggregator may be provided which will aggregate over the values in that category.For example we may load population data for locations around the world broken down by sex and age-group. If we specify aggregators over the 'AgeGrp' and 'Sex' indexes we can see the aggregated values for each of those groups (note that we do not have to specify an aggregator for the outer index since we specify the aggregators over the subgroups in this case the 'Sex'):<jupyter_code>from bokeh.sampledata.population import data as population_data 

pop_df = population_data[population_data.Year == 2020].set_index(['Location', 'AgeGrp', 'Sex'])[['Value']]

pn.widgets.Tabulator(value=pop_df, hierarchical=True, aggregators={'Sex': 'sum', 'AgeGrp': 'sum'}, height=400)<jupyter_output><empty_output><jupyter_text>PaginationWhen working with large tables we sometimes can't send all the data to the browser at once. In these scenarios we can enable pagination, which will fetch only the currently viewed data from the server backend. This may be enabled by setting `pagination='remote'` and the size of each page can be set using the `page_size` option:<jupyter_code>large_df = pd._testing.makeCustomDataframe(100000, 5)
%%time
paginated_table = pn.widgets.Tabulator(large_df, pagination='remote', page_size=10)
paginated_table<jupyter_output><empty_output><jupyter_text>Contrary to the `'remote'` option, `'local'` pagination entirely loads the data but still allows to display it on multiple pages.<jupyter_code>%%time
medium_df = pd._testing.makeCustomDataframe(10000, 5)
paginated_table = pn.widgets.Tabulator(large_df, pagination='local', page_size=10)
paginated_table<jupyter_output><empty_output><jupyter_text>FilteringA very common scenario is that you want to attach a number of filters to a table in order to view just a subset of the data. You can achieve this through callbacks or other reactive approaches but the  `.add_filter` method makes it much easier. Constant and Widget filtersThe simplest approach to filtering is to select along a column with a constant or dynamic value. The `.add_filter` method allows passing in constant values, widgets and parameters. If a widget or parameter is provided the table will watch the object for changes in the value and update the data in response. The filtering will depend on the type of the constant or dynamic value:- scalar: Filters by checking for equality- `tuple`: A tuple will be interpreted as range.- `list`/`set`: A list or set will be interpreted as a set of discrete scalars and the filter will check if the values in the column match any of the items in the list.As an example we will create a DataFrame with some data of mixed types:<jupyter_code>mixed_df = pd._testing.makeMixedDataFrame()
filter_table = pn.widgets.Tabulator(mixed_df)
filter_table<jupyter_output><empty_output><jupyter_text>Now we will start adding filters one-by-one, e.g. to start with we add a filter for the `'A'` column, selecting a range from 0 to 3:<jupyter_code>filter_table.add_filter((0, 3), 'A')<jupyter_output><empty_output><jupyter_text>Next we add dynamic widget based filter, a `RangeSlider` which allows us to further narrow down the data along the `'A'` column:<jupyter_code>slider = pn.widgets.RangeSlider(start=0, end=3, name='A Filter')
filter_table.add_filter(slider, 'A')<jupyter_output><empty_output><jupyter_text>Lastly we will add a `MultiSelect` filter along the `'C'` column:<jupyter_code>select = pn.widgets.MultiSelect(options=['foo1', 'foo2', 'foo3', 'foo4', 'foo5'], name='C Filter')
filter_table.add_filter(select, 'C')<jupyter_output><empty_output><jupyter_text>Now let's display the table alongside the widget based filters:<jupyter_code>pn.Row(
    pn.Column(slider, select),
    filter_table
)<jupyter_output><empty_output><jupyter_text>After filtering you can inspect the current view with the `current_view` property:<jupyter_code>filter_table.current_view<jupyter_output><empty_output><jupyter_text>Function based filtering For more complex filtering tasks you can supply a function that should accept the DataFrame to be filtered as the first argument and must return a filtered copy of the data. Let's start by loading some data.<jupyter_code>import sqlite3

from bokeh.sampledata.movies_data import movie_path

con = sqlite3.Connection(movie_path)

movies_df = pd.read_sql('SELECT Title, Year, Genre, Director, Writer, imdbRating from omdb', con)
movies_df = movies_df[~movies_df.Director.isna()]

movies_table = pn.widgets.Tabulator(movies_df, pagination='remote', layout='fit_columns', width=800)<jupyter_output><empty_output><jupyter_text>By using the `pn.bind` function, which binds widget and parameter values to a function, complex filtering can be achieved. E.g. here we will add a filter function that uses tests whether the string or regex is contained in the 'Director' column of a listing of thousands of movies:<jupyter_code>director_filter = pn.widgets.TextInput(name='Director filter', value='Chaplin')

def contains_filter(df, pattern, column):
    if not pattern:
        return df
    return df[df[column].str.contains(pattern)]
    
movies_table.add_filter(pn.bind(contains_filter, pattern=director_filter, column='Director'))    

pn.Row(director_filter, movies_table)<jupyter_output><empty_output><jupyter_text>Client-side filteringIn addition to the Python API the Tabulator widget also offers a client-side filtering API, which can be exposed through `header_filters` or by manually adding filters to the rendered Bokeh model. The API for declaring header filters is almost identical to the API for defining [Editors](Editors). The `header_filters` can either be enabled by setting it to `True` or by manually supplying filter types for each column. The types of filters supports all the same options as the editors, in fact if you do not declare explicit `header_filters` the tabulator will simply use the defined `editors` to determine the correct filter type:<jupyter_code>bokeh_editors = {
    'float': {'type': 'number', 'max': 10, 'step': 0.1},
    'bool': {'type': 'tickCross', 'tristate': True, 'indeterminateValue': None},
    'str': {'type': 'autocomplete', 'values': True}
}

header_filter_table = pn.widgets.Tabulator(
    df[['float', 'bool', 'str']], height=140, width=400, layout='fit_columns',
    editors=bokeh_editors, header_filters=True
)

header_filter_table<jupyter_output><empty_output><jupyter_text>When a filter is applied client-side the `filters` parameter is synced with Python. The definition of `filters` looks something like this:```[{'field': 'Director', 'type': '=', 'value': '<NAME>'}]```Try applying a filter and then inspect the `filters` parameter:<jupyter_code>header_filter_table.filters<jupyter_output><empty_output><jupyter_text>For all supported filtering types see the [Tabulator Filtering documentation](http://tabulator.info/docs/4.9/filter).If we want to change the filter type for the `header_filters` we can do so in the definition by supplying a dictionary indexed by the column names and then either providing a dictionary which may define the `'type'`, a comparison `'func'`, a `'placeholder'` and any additional keywords supported by the particular filter type.<jupyter_code>movie_filters = {
    'Title': {'type': 'input', 'func': 'like', 'placeholder': 'Enter title'},
    'Year': {'placeholder': 'Enter year'},
    'Genre': {'type': 'input', 'func': 'like', 'placeholder': 'Enter genre'},
    'Director': {'type': 'input', 'func': 'like', 'placeholder': 'Enter director'},
    'Writer': {'type': 'input', 'func': 'like', 'placeholder': 'Enter writer'},
    'imdbRating': {'type': 'number', 'func': '>=', 'placeholder': 'Enter minimum rating'}
}

filter_table = pn.widgets.Tabulator(
    movies_df, pagination='remote', layout='fit_columns', page_size=10, sizing_mode='stretch_width',
    header_filters=movie_filters
)
filter_table<jupyter_output><empty_output><jupyter_text>DownloadingThe `Tabulator` also supports triggering a download of the data as a CSV or JSON file dependending on the filename. The download can be triggered with the `.download()` method, which optionally accepts the filename as the first argument.To trigger the download client-side (i.e. without involving the server) you can use the `.download_menu` method which creates a `TextInput` and `Button` widget, which allow setting the filename and triggering the download respectively:<jupyter_code>download_df = pd.DataFrame(np.random.randn(10, 5), columns=list('ABCDE'))

download_table = pn.widgets.Tabulator(download_df)

filename, button = download_table.download_menu(
    text_kwargs={'name': 'Enter filename', 'value': 'default.csv'},
    button_kwargs={'name': 'Download table'}
)

pn.Row(
    pn.Column(filename, button),
    download_table
)<jupyter_output><empty_output><jupyter_text>StreamingWhen we are monitoring some source of data that updates over time, we may want to update the table with the newly arriving data. However, we do not want to transmit the entire dataset each time. To handle efficient transfer of just the latest data, we can use the `.stream` method on the `Tabulator` object:<jupyter_code>stream_df = pd.DataFrame(np.random.randn(10, 5), columns=list('ABCDE'))

stream_table = pn.widgets.Tabulator(stream_df, layout='fit_columns', width=450)
stream_table<jupyter_output><empty_output><jupyter_text>As example, we will schedule a periodic callback that streams new data every 1000ms (i.e. 1s) five times in a row:<jupyter_code>def stream_data(follow=True):
    stream_df = pd.DataFrame(np.random.randn(10, 5), columns=list('ABCDE'))
    stream_table.stream(stream_df, follow=follow)

pn.state.add_periodic_callback(stream_data, period=1000, count=5)<jupyter_output><empty_output><jupyter_text>If you are viewing this example with a live Python kernel you will be able to watch the table update and scroll along. If we want to disable the scrolling behavior, we can set `follow=False`:<jupyter_code>stream_data(follow=False)<jupyter_output><empty_output><jupyter_text>PatchingIn certain cases we don't want to update the table with new data but just patch existing data.<jupyter_code>patch_table = pn.widgets.Tabulator(df[['int', 'float', 'str', 'bool']])
patch_table<jupyter_output><empty_output><jupyter_text>The easiest way to patch the data is by supplying a dictionary as the patch value. The dictionary should have the following structure:```python{    column: [        (index: int or slice, value),        ...    ],    ...}```    As an example, below we will patch the 'bool' and 'int' columns. On the `'bool'` column we will replace the 0th and 2nd row and on the `'int'` column we replace the first two rows:<jupyter_code>patch_table.patch({
    'bool': [
        (0, False),
        (2, False)
    ],
    'int': [
        (slice(0, 2), [3, 2])
    ]
})<jupyter_output><empty_output><jupyter_text>Static ConfigurationPanel does not expose all options available from Tabulator, if a desired option is not natively supported, it can be set via the `configuration` argument.  This dictionary can be seen as a base dictionary which the tabulator object fills and passes to the Tabulator javascript-library.As an example, we can turn off sorting and resizing of columns by disabling the `headerSort` and `resizable` options.<jupyter_code>df = pd.DataFrame({
    'int': [1, 2, 3],
    'float': [3.14, 6.28, 9.42],
    'str': ['A', 'B', 'C'],
    'bool': [True, False, True],
    'date': [dt.date(2019, 1, 1), dt.date(2020, 1, 1), dt.date(2020, 1, 10)]
}, index=[1, 2, 3])

df_widget = pn.widgets.Tabulator(df, configuration={'columnDefaults': {
    'resizable': False,
    'headerSort': True
}})

df_widget.servable()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11259313770582283, 'fraction_numerical': 0.008493545518658203, 'mean_word_length': 6.021313240043057, 'pattern_counts': {'":': 0, '<': 193, '<?xml version=': 0, '>': 193, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '47', 'dir': 'jupyter-structured-clean-dedup', 'id': '12751', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 9810, 'n_tokens_neox': 9323, 'n_words': 3545, 'path': 'examples/reference/widgets/Tabulator.ipynb', 'repo_name': 'blelem/panel', 'size': '32623'}