I can do the first part with
df.with_columns(pl.col("^.+D$"))
and the second part with
df.with_columns(pl.col(pl.datatypes.Datetime))
How do I join the two conditions with an "and"?
You could use selectors:
import polars.selectors as cs
df.with_columns(cs.datetime() & cs.ends_with('D'))
# or
df.with_columns(cs.datetime() & cs.matches('^.+D$'))
Selectors support set operations such as:
UNION: A | B
INTERSECTION: A & B
DIFFERENCE: A - B
COMPLEMENT: ~A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With