great-tables icon indicating copy to clipboard operation
great-tables copied to clipboard

fix: Convert Polars container dtype entries to list in _get_cell (#778)

Open KristijanArmeni opened this issue 1 month ago • 0 comments

Summary

This pull request adds a small fix that ensures that _get_cell returns a list rather than pl.Series if cell entry is a container dtype (pl.List or pl.Array). This makes its behavior with polars dataframes consistent with _get_cell for pandas data frames which return lists for container dtypes.

I went ahead and thought this was the best place to address #778 which surfaced as a syntax bug when running one of the gt-extras tutorials with polars. Happy to consider other solutions in case it warrants a fix elsewhere in the code base!

Changes

  • _tbl_data._get_cell: check if retrieved cell entry is either a container data type and convert to list.
  • tests/test_tbl_data.py: adds df_container_dtypes fixture and test_get_cell_container_dtypes test

Related GitHub Issues and PRs

  • Ref: #778

Checklist

  • [x] I understand and agree to the Code of Conduct.
  • [x] I have followed the Style Guide for Python Code as best as possible for the submitted code.
  • [x] I have added pytest unit tests for any new functionality.

KristijanArmeni avatar Oct 31 '25 19:10 KristijanArmeni