We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import polars as pl df=pl.DataFrame({'text':["I found <amt> yesterday."], 'amt': ["$1"]}) df = df.with_columns(pl.col("text").str.replace_all(f"<amt>", pl.col('amt'), literal=True).alias("text2")) print(df) # ┌──────────────────────────┬─────┬───────────────────────┐ # │ text ┆ amt ┆ text2 │ # │ --- ┆ --- ┆ --- │ # │ str ┆ str ┆ str │ # ╞══════════════════════════╪═════╪═══════════════════════╡ # │ I found <amt> yesterday. ┆ $1 ┆ I found $1 yesterday. │ # └──────────────────────────┴─────┴───────────────────────┘ df2=pl.DataFrame({'text':["I found <amt> yesterday.", "I lost <amt> yesterday."], 'amt': ["$1","$2"]}) df2 = df2.with_columns(pl.col("text").str.replace_all(f"<amt>", pl.col('amt'), literal=True).alias("text2")) print(df2) # ┌──────────────────────────┬─────┬─────────────────────┐ # │ text ┆ amt ┆ text2 │ # │ --- ┆ --- ┆ --- │ # │ str ┆ str ┆ str │ # ╞══════════════════════════╪═════╪═════════════════════╡ # │ I found <amt> yesterday. ┆ $1 ┆ I found yesterday. │ # │ I lost <amt> yesterday. ┆ $2 ┆ I lost yesterday. │ # └──────────────────────────┴─────┴─────────────────────┘
$ POLARS_VERBOSE=1 python tmp2.py shape: (1, 3) ┌──────────────────────────┬─────┬───────────────────────┐ │ text ┆ amt ┆ text2 │ │ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str │ ╞══════════════════════════╪═════╪═══════════════════════╡ │ I found <amt> yesterday. ┆ $1 ┆ I found $1 yesterday. │ └──────────────────────────┴─────┴───────────────────────┘ shape: (2, 3) ┌──────────────────────────┬─────┬─────────────────────┐ │ text ┆ amt ┆ text2 │ │ --- ┆ --- ┆ --- │ │ str ┆ str ┆ str │ ╞══════════════════════════╪═════╪═════════════════════╡ │ I found <amt> yesterday. ┆ $1 ┆ I found yesterday. │ │ I lost <amt> yesterday. ┆ $2 ┆ I lost yesterday. │ └──────────────────────────┴─────┴─────────────────────┘
Increasing the number of rows from 1-2 causes the bug to appear on both ExprStringNameSpace.replace and ExprStringNameSpace.replace_all.
I believe that this bug is only present when the "$" is in expr passed to the val parameter.
The 1 row example performs how I would expect.
--------Version info--------- Polars: 1.5.0 Index type: UInt32 Platform: Linux-5.15.0-91-generic-x86_64-with-glibc2.35 Python: 3.10.10 (main, Jun 12 2024, 09:40:01) [GCC 11.4.0] ----Optional dependencies---- adbc_driver_manager: <not installed> cloudpickle: 3.0.0 connectorx: <not installed> deltalake: <not installed> fastexcel: <not installed> fsspec: 2024.6.1 gevent: <not installed> great_tables: <not installed> hvplot: <not installed> matplotlib: <not installed> nest_asyncio: 1.6.0 numpy: 1.26.4 openpyxl: <not installed> pandas: 1.5.3 pyarrow: 17.0.0 pydantic: 2.8.2 pyiceberg: <not installed> sqlalchemy: <not installed> torch: 2.4.0+cu121 xlsx2csv: <not installed> xlsxwriter: <not installed>``` </details>
The text was updated successfully, but these errors were encountered:
I'm going to look into this over the next couple days to see if I can fix this.
Sorry, something went wrong.
PR for fix. #19366
And a followup. When I read this, I missed that the issue affects replace as well. This followup PR fixes the issue for replace as well. #19413
replace
Successfully merging a pull request may close this issue.
Checks
Reproducible example
Log output
Issue description
Increasing the number of rows from 1-2 causes the bug to appear on both ExprStringNameSpace.replace and ExprStringNameSpace.replace_all.
I believe that this bug is only present when the "$" is in expr passed to the val parameter.
Expected behavior
The 1 row example performs how I would expect.
Installed versions
The text was updated successfully, but these errors were encountered: