-
Notifications
You must be signed in to change notification settings - Fork 947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for displaying pandas DataFrame as an interactive table #1373
Conversation
@desertproject Nice one :) One question though: Instead of expecting (forcing) the user to serialize the dataframe to JSON in a specific orientation, why don't we just accept the DataFrame element and call This way people wouldn't have to serialize/deserialize their dataframes throughout and could just pass a DataFrame at any point without having to worry about the underlying implementation. |
@desertproject Cool feature! Could you please create an E2E test for it, so we can support it towards the future? I'd also love some (Forget the screenshot, I just seen it in the issue.) |
@hadarsharon That's a great idea! I had thought of something similar but wasn’t sure exactly where it would fit. Using the |
@dokterbob I don’t have any experience with E2E testing or Cypress, but I’d be happy to give it a try! Could you provide some guidance on the specific tests you’d like to see? I can also take care of the cookbook entry without any problem. |
Basically, you'd create a test suite similar to the ones already there: https://github.com/Chainlit/chainlit/tree/main/cypress/e2e Create a test project setup to use your feature, then test everything you'd normally test for it. E.g. return a dataframe, ensure it's properly rendered. If there's interaction possible, simulate it. I highly recommend to use something like Claude if you haven't written tests before (but of course, check the work for common slipups!). Similarly unit tests for Python code would be great as well. Note how the unit tests are laid out to match the Python modules. |
- Updated Dataframe class to accept pandas DataFrame directly. - Automatically serialize DataFrame to JSON with orient="split" in __post_init__. - Simplified interface, removing the need for users to manually serialize data.
- Added loading state to DataGrid using the loading prop. - Refactored data parsing logic to handle loading more cleanly.
- Created sample DataFrame with 15 rows (more than 10) in main.py to test pagination - Added Cypress test to validate Dataframe rendering, sorting, pagination, and rows per page functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely looks good to me.
I'd like to ask @willydouhard to take a quick look at it as well, other than that we're good to merge!
When will a new tag for this change be released? Eager to try it out:) |
@sundar-sarvam Should be in today's 2.0.dev1 pre-release. @desertproject We'd love a PR also for the docs https://github.com/Chainlit/docs! |
I'll take care of it! |
This is an attempt to address issue #1350, and it may serve as a basis for future improvements and better implementations.
To use this functionality, follow these steps: