How to Add Search Functionality to Pandas DataFrames with iTables

This quick tutorial shows how to add search functionality to Pandas DataFrames using iTables. For a complete introduction to iTables, see our Getting Started with iTables: Interactive DataFrames in Python guide.

The Problem

Finding specific values in large DataFrames typically requires writing .query() statements or boolean indexing like df[df[‘Country’].str.contains(‘United’)]. For quick exploration, you need an instant search across all columns without writing filter code. iTables provides a built-in search box that filters your DataFrame in real time as you type.

The Solution

Display your DataFrame with iTables to enable the search box.

 
from itables import init_notebook_mode, show
from itables.sample_dfs import get_countries

init_notebook_mode(all_interactive=True)
df = get_countries(html=False)
show(df, searching=True)

The searching=True parameter is the default, so the search box appears automatically.

search pandas itables 

The search box appears at the top right of the table. Type any text to filter across all columns simultaneously. Searches are case-insensitive by default, so typing “united” finds “United States” and “United Kingdom.” Results update instantly as you type, and clearing the search box shows the full dataset again. When a search is active, the table displays “Showing X to Y of Z entries (filtered from W total entries),” so you know how many matches were found.

search pandas itables 

Partial matches work: “ger” finds “Germany,” “Algeria,” and “Niger.” The search looks across every visible column, treating numbers as text for matching purposes.

The search works with any data type in your DataFrame. Text columns match substrings, numeric columns match digits wherever they appear, and date columns can be searched by year or month. This makes finding specific entries quick without writing filter conditions.

Disable Search When Not Needed

Turn off the search box for presentations or finalized reports.

 
show(df, searching=False)

The search box disappears, leaving only the data table.

search pandas itables 

Disable search when presenting finalized results where exploration isn’t needed, when embedding tables in reports where search would be distracting, or for small DataFrames where all data fits on one screen. For executive summaries or printed reports, removing the search box creates a cleaner, more focused presentation.

Conclusion

The search box is enabled by default in iTables. Just start typing to instantly filter your DataFrame without writing any query code, and the original DataFrame stays unchanged.

Leave a Reply

Your email address will not be published. Required fields are marked *