Question
ComputeError: dynamic pattern length in 'str.replace' expressions is not supported yet
What is the polars expression way to achieve this,
df = pl.from_repr("""
┌───────────────────────────────┬───────────────────────────┐
│ document_url ┆ matching_seed_url │
│ --- ┆ --- │
│ str ┆ str │
╞═══════════════════════════════╪═══════════════════════════╡
│ https://document_url.com/1234 ┆ https://document_url.com/ │
│ https://document_url.com/5678 ┆ https://document_url.com/ │
└───────────────────────────────┴───────────────────────────┘""")
df = df.with_columns(
pl.when(pl.col("matching_seed_url").is_not_null())
.then(pl.col("document_url").str.replace(pl.col("matching_seed_url"), ""))
.otherwise(pl.lit(""))
.alias("extracted_id"))
I get,
ComputeError: dynamic pattern length in 'str.replace' expressions is not supported yet
how do I extract 1234, 5678 here
2 58
2