Open braaannigan opened 1 year ago
You can use pl.duration
, although I notice a bug: comparing using a pl.Duration
with a pl.duration
fails when the pl.Duration
doesn't have units of ms
.
# this creates an error
df.select(pl.col("date").diff() < pl.duration(hours=2))
# this does not
df.select(pl.col("date").diff().cast(pl.Duration("ms")) < pl.duration(hours=2))
Ok, my statement about the bug is not the case, as per all of these working:
pl.select(pl.lit(timedelta(hours=1), dtype=pl.Duration("ms")) - pl.duration(hours=1))
pl.select(pl.lit(timedelta(hours=1), dtype=pl.Duration("us")) - pl.duration(hours=1))
pl.select(pl.lit(timedelta(hours=1), dtype=pl.Duration("ns")) - pl.duration(hours=1))
You can use
pl.duration
, although I notice a bug: comparing using apl.Duration
with apl.duration
fails when thepl.Duration
doesn't have units ofms
.# this creates an error df.select(pl.col("date").diff() < pl.duration(hours=2)) # this does not df.select(pl.col("date").diff().cast(pl.Duration("ms")) < pl.duration(hours=2))
Yes, I just think Polars already has a parser for the strings and they are really snappy so why not?
Problem description
The string intervals are great. If would be nice to use them to filter
pl.Duration
columns: