Skip to content

Conversation

@adilkassim
Copy link

📝 Summary

Closes #7945
This PR enables search functionality for index columns in the PandasTableManager.

🔍 Description of Changes

Currently, the table search logic only scans DataFrame columns. When users call df.value_counts(), the resulting labels are stored in the index, which made them unsearchable.

Changes:

  • Updated PandasTableManager.search() to detect non-default indexes (like those produced by value_counts).
  • The logic now temporarily resets the index to a column during the search process so the underlying search engine can match against index labels.
  • Verified that searching for specific strings (e.g., "Dave") and single characters now works correctly.
  • Automated Unit Test: Added test_search_value_counts to tests/_plugins/ui/_impl/tables/test_pandas_table.py

Testing:

  • Manually verified in a marimo notebook.
  • Local Test Suite: Ran the full Python test suite; 7,245 tests passed. (Note: test_smoke_test failed due to a pre-existing collection issue in the main branch).

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Tests have been added for the changes made.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Pull request title is a good summary of the changes - it will be used in the release notes.
@vercel
Copy link

vercel bot commented Jan 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 23, 2026 2:32am

Request Review

@github-actions
Copy link

github-actions bot commented Jan 23, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@adilkassim
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

searches columns, not the index. This override resets the index (if needed)
before searching, making index values searchable.
"""
# Check if we need to reset the index (same logic as to_json_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably pull out the logic in to_json_str to shared functions to share more of this code

data_for_search = data_for_search.reset_index()

# Create a temporary manager with reset index for searching
temp_manager = PandasTableManager(data_for_search)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we just return return PandasTableManager(data_for_search).search(query)

# Default index, use parent search method and convert result back to PandasTableManager
searched_manager = super().search(query)
searched_data = searched_manager.data.to_native()
return PandasTableManager(searched_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think return super().search(query) would be fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants