Comments (3)
This seems to have something to do with setting upper_bound
.
The documentation states:
When operating on a DataFrame, the schema does not need to be tracked or pre-determined, as the result will be eagerly evaluated, so you can leave this parameter unset.
but it does seem to have an effect even in eager mode:
ds.select(pl.col("A").list.to_struct(upper_bound=3).struct.field("*")) # Works now!
shape: (3, 3)
┌─────────┬─────────┬─────────┐
│ field_0 ┆ field_1 ┆ field_2 │
│ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str │
╞═════════╪═════════╪═════════╡
│ A ┆ B ┆ C │
│ D ┆ null ┆ null │
│ E ┆ F ┆ null │
└─────────┴─────────┴─────────┘
However, it seems like I need to "correctly" guess the number of upper_bound
, e.g. this will break:
ds.select(pl.col("A").list.to_struct(upper_bound=999).struct.field("*"))
StructFieldNotFoundError: field_272
(and in fact, the "272" in field_272
is random, it's different each time. Probably due to parallelism).
from polars.
This cannot be solved dynamically. Polars needs to know the data-type before running the query on the actual data. So if your upper bound is incorrect, Polars will expand fields that don't exist in the data.
There is not much we can do here.
from polars.
Ah I see - it's a consequence of LazyFrame in that ds.with_columns(...)
has similar semantics as ds.lazy().with_columns(...).collect()
from polars.
Related Issues (20)
- Change `dt.week()` to be more consistent with `dt.year()` (Gregorian Year) HOT 1
- Deserializing list-of-null data leads to incorrect results
- Cannot instantiate Series of type Struct(List(UInt64)) with large integer value
- Aliasing Columns Names in Map_Element () with Dataclass Fields HOT 3
- Parallel string operations HOT 1
- add option for `to_dummies` to respect nulls
- `.mean_horizontal()` does not work with `pl.datetime` (but `.mean()` does)
- floor_div runtime error for i64, u32 and u64
- Support No-op round() on Int columns HOT 1
- `sort_by("col", nulls_last=True).over("other")` does not put nulls at the end HOT 2
- Native `delta` reader and writer using delta-kernel-rs
- ComputeError: could not append value when creating Polars DataFrame HOT 4
- `pl.Expr.list.get` returns erroneous results after version `0.20.19` HOT 3
- Implement (de)serialization of Series/DataFrames using IPC
- `pl.Expr.list.get` raises error on null values. HOT 4
- polars.read_delta from a GCP bucket using service account
- `scan_parquet` expects columns to be in the same order iff `POLARS_FORCE_ASYNC=1` or scanning against cloud, local works regardless of ordering HOT 1
- PanicException when doing a `scan_parquet` on files with mismatching schemas
- Loading wide parquet data with `scan_parquet` is orders of magnitude slower than long data HOT 1
- `pl.Expr`.sort_by('date').over("code") doesn't sort in fact. HOT 2
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.