Comments (5)
The int
version working seems a bit odd because 4
is being "replaced" by [4]
I did notice that forcing the default value is possible:
df_str.select(
pl.col("a").list.eval(
pl.element().replace({"1": ["11", "111"], "2": ["22"]}, default=pl.concat_list(pl.element()))
)
)
# shape: (1, 1)
# ┌────────────────────────────────┐
# │ a │
# │ --- │
# │ list[list[str]] │
# ╞════════════════════════════════╡
# │ [["11", "111"], ["22"], ["4"]] │
# └────────────────────────────────┘
from polars.
ahh i figured that happens to force a consistent datatype. Neat workaround with the default though!
from polars.
I too am hoping for this to be resolved!
from polars.
@ThomasMAhern What do you need resolved?
It seems that both examples should raise here and the fact that the int case works is a "bug"?
EDIT: Ah, the return_dtype
docs say: "the data type is determined automatically based on the other inputs" - so perhaps I am mistaken.
Just experimenting further, something else seems broken:
df_int.with_columns(
a1 = pl.col("a").list.eval(pl.element().replace("1", [["a", "b"]]))
)
# shape: (1, 2)
# ┌───────────┬────────────────────────────┐
# │ a ┆ a1 │
# │ --- ┆ --- │
# │ list[i64] ┆ list[list[str]] │
# ╞═══════════╪════════════════════════════╡
# │ [1, 2, 4] ┆ [["a", "b"], ["2"], ["4"]] │
# └───────────┴────────────────────────────┘
1
is being cast to "1"
then the replace succeeds?
from polars.
It seems I'm able to get the expected output if I specify return_dtype=pl.List(pl.String)
from polars.
Related Issues (20)
- `concat_list` PanicException inside `agg()`
- A regression in numpy-to-series conversion
- PanicException when using `collect(streaming=True)` on an empty `.parquet` file with joins.
- Regression: `.collect()` no longer generates `unexpected keywords` error. HOT 1
- Shift() fails if the argument is contained in a column HOT 1
- Support boolean iterable for argument `descending` in `DataFrame.set_sorted()`
- polars.exceptions.ComputeError: could not append value: "2024-03-05T17:39:39Z" of type: str to the builder; make sure that all rows have the same schema or consider increasing `infer_schema_length` HOT 1
- Re-aliasing existing `LazyFrame` column name does not return the last version HOT 2
- dt.trunctate is 3-4x slower in polars compared to pandas HOT 2
- `.struct.with_fields` PanicException inside `agg`
- add `show` method for syntax compatibility with pyspark/duckdb/etc dataframe API
- `gather` in `agg` context gathers values from other groups
- ShapeError: filter's length: 155 differs from that of the series: 0 HOT 9
- Version 0.20.30 bug HOT 4
- `.list.to_array()` fails if first element of a list column is excluded HOT 2
- `scan_parquet` + `with_row_index` causing `pl.len()` to return 0 HOT 1
- full join with coalesce=True panics if more key expressions are used than columns in a frame
- LazyFrames containing nested List types will cause panic in `collect()` HOT 1
- Another "coalesce=False" `join` schema issue HOT 2
- performance slowdown with `Expr.alias` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polars.