With pure Python, it is relatively simple to do ord(A) == 65, and as a slow Polars method, it is possible to do:
pl.Series(["A", "B", "C"]).cast(pl.Binary).map_elements(lambda x: ord(x)) == pl.Series([65,66,67])
pl.Series(["A", "B", "C"]).map_elements(lambda x: ord(x)) == pl.Series([65,66,67])
Is there a method (outside of writing a rust implementation, which would be simple, but potentially needless) to do this efficiently?
>Solution :
You could cast to list of pl.UInt8 as:
pl.Series(["A", "B", "C"]).cast(pl.Binary).cast(pl.List(pl.UInt8))
Subsequently, you can use the methods available under the expr.list attribute to work with the list.
Is that good enough for your use-case?