Skip to main content

PandasRowSelectionInput

Pandas DataFrame row selection input widget for selecting rows from tabular data.

Examples

Basic Usage

This example runs a form with a single page containing the widget

Example Code

import pandas as pd

from abstra.forms import PandasRowSelectionInput, run

data = [
{"Country": "USA", "Population": "32,700,000"},
{"Country": "China", "Population": "1,300,000,000"},
{"Country": "Japan", "Population": "126,000,000"},
]
df = pd.DataFrame(data)

# Create a page with the widget
example_page = [
PandasRowSelectionInput(df=df, key="my-selection", label="Select country")
]

# Run the form
result = run([example_page])

# Print the result
print(result)

Parameters

NameDescriptionTypeDefault
df (required)The pandas DataFrame to display.pd.DataFrameNone
keyIdentifier for the widget.strNone
requiredWhether row selection is required before proceeding.boolTrue
hintHelp text displayed below the input.strNone
full_widthWhether the table should take up the full width of its container.boolTrue
display_indexWhether to display row indices.boolFalse
disabledWhether the input is non-interactive.boolFalse
labelText label displayed above the table.str''
filterableWhether the table is filterable.boolFalse
multipleWhether multiple rows can be selected.boolFalse
minMinimum number of rows that must be selected when multiple=True.intNone
maxMaximum number of rows that can be selected when multiple=True.intNone
page_sizeNumber of rows to display per page.int10
errorsPre-defined validation error messages to display.Union[List[str], str]None
pagination_always_visibleWhether pagination controls are always visible.boolTrue

State Value

Union[List[Dict], Dict, None]: The selected row(s) from the DataFrame. If multiple is True, this can be a list of rows as dicts; otherwise, it is a single dict or None.

info

This is the type of the value that this widget holds. It will show up when accessing widget's state item.

This also defines which value type can be used on initial_state