posit-dev / great-tables

Make awesome display tables using Python.
https://posit-dev.github.io/great-tables/
MIT License
1.44k stars 50 forks source link

Refactor: do not route vals_ methods through GT object #266

Open machow opened 3 months ago

machow commented 3 months ago

Currently, functions like vals.fmt_number() work as follows:

This is problematic for two reasons:

Removing use of GT

Fortunately, it seems that GT.fmt_* methods don't make much use of the GT object. Uses seem to be largely:

It seems like we could pretty easily run vals.fmt_* funcs straight over formatter logic. This would let us remove the pandas dependency.

Alternatively..

An alternative would be for us to support GT(SomeInBuiltFrame). GT's core logic does not require a very beefed up DataFrame implementation. We could get away with a class that's essentially a dictionary of same-length lists. This might actually be easier, since we wouldn't need to refactor the formatter code.

machow commented 3 months ago

Alternatively alternatively...

We could support inputting a pandas series or polars series as the input values. We have the machinery to detect these, and at that point do pandas/polars specific things w/o creating any dependencies.