Skip to content

Add pandas DataFrame support for table rendering in reports#24

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/add-pandas-dataframe-support
Open

Add pandas DataFrame support for table rendering in reports#24
Copilot wants to merge 3 commits into
mainfrom
copilot/add-pandas-dataframe-support

Conversation

Copilot AI commented Dec 27, 2025

Copy link
Copy Markdown
Contributor
  • Add pandas as an optional dependency to pyproject.toml
  • Implement pandas DataFrame handler in html.py
  • Add tests for pandas DataFrame support
  • Update README.rst to remove TODO and add pandas dataframe example
  • Update docs/usage.rst with pandas DataFrame documentation
  • Run tests to validate changes (all 16 tests pass)
  • Code review completed (no issues in new code)
  • CodeQL security scan passed (0 alerts)
  • Edge cases tested and validated
  • Final validation completed
  • Refactored TestPandasSupport to use tearDown method for cleanup consistency

Summary

Successfully implemented pandas DataFrame support for Otter reports. Refactored test cleanup to follow the same pattern as TestOtterBasics, using setUp/tearDown methods instead of try-finally blocks for better consistency and cleaner code.

Total changes: 5 files changed, 149 insertions(+), 9 deletions(-)

Original prompt

This section details on the original issue you should resolve

<issue_title>Add support for including pandas dataframes as tables in reports.</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: transientlunatic <4365778+transientlunatic@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for including pandas dataframes in reports Add pandas DataFrame support for table rendering in reports Dec 27, 2025
@transientlunatic transientlunatic marked this pull request as ready for review December 27, 2025 16:29
Copilot AI review requested due to automatic review settings December 27, 2025 16:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds optional pandas DataFrame support to Otter reports, completing a TODO item from the README. DataFrames can now be automatically rendered as styled HTML tables using the existing tabulate-based rendering system.

Key Changes:

  • Added optional pandas dependency with graceful fallback when unavailable
  • Implemented DataFrame-to-HTML conversion using the existing Bootstrap table styling
  • Added comprehensive test coverage with conditional pandas availability checks

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
otter/html.py Adds optional pandas import, dataframe_to_table() function, and registers DataFrame handler when pandas is available
pyproject.toml Defines pandas as an optional dependency under [project.optional-dependencies]
tests/test_otter.py Adds TestPandasSupport test class with two tests that skip gracefully when pandas is unavailable
README.rst Removes TODO, adds usage example demonstrating DataFrame rendering
docs/usage.rst Adds dedicated "Pandas DataFrames" section with usage examples and installation notes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_otter.py
except ImportError:
self.pandas_available = False
self.pd = None

Copilot AI Dec 27, 2025

Copy link

Choose a reason for hiding this comment

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

The TestPandasSupport class is missing a tearDown method to clean up resources. The test_pandas_dataframe_in_report method creates temporary directories but handles cleanup in a try-finally block within the test itself. For consistency with the existing TestOtterBasics class pattern (lines 24-38), consider adding a tearDown method to handle cleanup uniformly across all tests in this class.

Suggested change
def tearDown(self):
"""Clean up any temporary resources created by tests."""
# Remove a temporary directory if one was created and stored on the instance
if hasattr(self, "test_dir") and self.test_dir and os.path.isdir(self.test_dir):
shutil.rmtree(self.test_dir)

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refactored TestPandasSupport to use setUp/tearDown pattern for consistency with TestOtterBasics. The test_dir and test_file are now created in setUp and cleaned up in tearDown, eliminating the try-finally block. Commit: a97a8ba

@transientlunatic transientlunatic left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot Please address the comments from code review.

Co-authored-by: transientlunatic <4365778+transientlunatic@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for including pandas dataframes as tables in reports.

3 participants