polars
polars copied to clipboard
expressions everywhere
Problem description
''' df.with_columns([ pl.col("a").str.split("\d{3}").alias("z_a"), pl.col("a").str.replace(pl.col("b"),"").alias("z_b"), pl.col("a")str.extract_all_except(pl.col("b").alias("c_c"), pl.col("a").str.split_exact(pl.col("b").alias("c_d"), pl.col("a")str.replacel(pl.col("b", "").alias("c_c"), ] ) '''
What is your suggestion?
If you don't want to type pl.col
, you are free to rename it. It is your program.
import polars.col as c
You could create variables:
a = pl.col("a").str
b = pl.col("b")
df.with_columns([
a.split().alias(),
a.replace().alias(),
a.extract_all().alias(),
...
])
I typically use this preamble:
import polars as pl
from polars import col, when
This cleans up syntax a lot:
df.select([
when(col('a').is_in(col('b')).then(1)
.otherwise(2)
])
...etc.
we as of now cant do ny of the operation from obove
Can you spend a little more effort describing what your issue is?
I will close this issue as I don't see anything constructive here. If there is a better definition of the problem, a suggestion how to fix it and more effort to fill in our issue templates feel free to open a new issue.