Comments (4)
The first two cases is expected behavior, the third case is a bug. @coastalwhite could you check that third case out? For some reason concatenating with an empty LazyFrame
screws up the order in sink_parquet
.
from polars.
The first two cases were very unexpected to me. Can you explain them or point me to a resource that explains them? I'll elaborate on my thoughts too:
Regarding the first case, I'm not comparing df1
and df2
. I'm comparing df2
and df2.collect()
.lazy(). To me it seems that if you collect a dataframe and make it lazy again, you're left with the original lazyframe. It should be equivalent to the identity operation. If there's an error, it should happen when you call
.collect()on the LazyFrame, not when you compare it to the original lazyframe. I don't think it's unlikely in a big chain of computations on a lazyframe that someone's gonna call
.collect()somewhere and then
.lazy()again somewhere else, and I don't think they're gonna expect their frame to be different because of it. Also, my intuition of what the correct behavior is has been guided by
DataFrame`s, so when I saw that
df0 = pl.DataFrame()
df1 = pl.DataFrame({"a": []})
df2 = pl.concat([df0, df1])
yielded a concatenated DataFrame
no problem, I figured there was a problem in first example case. I'd still argue that if my first example is expected, then this snippet here is unexpected.
Regarding the second case, I again think that writing a LazyFrame and the reading it again should be the identity operation. It's essentially the same argument as for the first case. Here's an alternate formulation of the second example where I concatenate DataFrame
s and then make it lazy, and there's no problem here:
df0 = pl.DataFrame()
df1 = pl.DataFrame({"a": [1, 2, 3]})
df2 = pl.concat([df0, df1]).lazy()
df2.sink_parquet(file)
df3 = pl.scan_parquet(file)
assert_frame_equal(df2, df3)
I'd argue that either both this and example 2 should fail, or both should succeed.
I have now clarified what I see as the issue. If this clears it up and cases 1 and/or 2 indeed are issues, then I apologize for not adding this to the original issue description. I simply didn't think to.
from polars.
I am looking into the 3rd case. I will discuss the other cases with @orlp and come back.
from polars.
Should these not produce the same result?
>>> pl.concat([df0, df1]).collect_schema()
# Schema()
>>> pl.concat([df1, df0]).collect_schema()
# Schema([('a', Null)])
from polars.
Related Issues (20)
- DataFrame.write_database() not passing along engine_options when using ADBC HOT 1
- Documentation suggestion: cover options for DataFrame creation from different Python data structures in User Guide and add example of list of dicts to API docs
- Calculate Entropy for non-numerical columns HOT 2
- Feature (rust, python) make the polars-python module public HOT 1
- Need fill_infinity feature HOT 2
- Inconsistent API of join_asof
- unreachable code panic on invalid argument for unique HOT 1
- Extract Underlying Coding from a Categorical or Enum Datatype HOT 2
- Cast categorical and enum data types directly to signed integers
- scan_csv should be able to read "0" and "1" into a boolean type
- serde deserialisation of AnyValue doesn't work HOT 2
- Problem with list eval on length 1 dataframes
- Add example showing how to unpivot multiple columns HOT 1
- Add pre-filtered decode to new-streaming Parquet source
- Dataframes that have both strings and categories cannot be serialized and deserialized from disk.
- LazyFrame.map_batches() ordering guarantees
- computation of list.len for null list seems incorrect HOT 1
- Schema for groupby-agg of literal raised to some power does not match `collect` result.
- Severe memory issues with `rolling` and `group_by`
- Schema inference fails when colums are produced without a name with pyodbc and sql server 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.