great-tables
great-tables copied to clipboard
epic: Add the `fmt_duration()` method
The fmt_duration() method would be useful to have for transforming numerical values (and time duration values) to well-formatted and customizable duration strings.
For me is the missing fmt_duration() almost showstopper as it literary breaks rendering any GT with duration column:
TypeError: '<' not supported between instances of 'datetime.timedelta' and 'int' error
The only workaround is to keep the duration columns as strings what is not very practical.
Looking forward to v0.11.0
Hey @vlcinsky, thanks for flagging this error. Can you say a bit more about what triggers this error, or provide an example? I'm trying to reproduce. I noticed a different error when using a timedelta in polars, but wasn't able to reproduce the error message you received.
Here's what I tried
import polars as pl
import pandas as pd
from datetime import timedelta
from great_tables import GT
# polars ---
# error: casting from Duration(Microseconds) to String not supported
GT(pl.DataFrame({"some_duration": [timedelta(1)]}))
# pandas ---
# works okay
GT(pd.DataFrame({"some_duration": [timedelta(1)]}))