Comments (4)
@avimallu Weird. Its a 14 core processor (13th gen i7)
from polars.
.over()
performs a group_by e.g.
(df2.group_by("group")
.agg(
pl.when(pl.col("random_value")==1)
.then(2)
.otherwise(pl.col("random_value"))
.alias("result")
)
)
But the lists would be exploded and the results joined back in the correct row order.
from polars.
I find it strange that it doesnt try to do 1 operation across all the groups simultaneously.
Why do you find it strange? You're explicitly asking to do a group-by (using over
) operation, and it's doing that.
What you seem to be asking for is for Polars to ignore that you've asked for an over
calculation, because the calculation's result is the same regardless of whether or not the group is present. That's something that could be achieved using LazyFrame
s, but I don't think it's implemented right now.
I'm also not able to reproduce your 20x slower timings, so there seems to be some optimization going on - in my case, it could be that it's parallelizing across cores efficiently - your recent issue (#15480) might point to having a processor with fewer available cores? 🤔
24.8 ms ± 886 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
107 ms ± 569 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
384 ms ± 10.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
from polars.
Hmm, forgot to turn off battery saver. Turned everything to max and activated all cores manually and got this
44.2 ms ± 2.74 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
24.8 ms ± 1.45 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
477 ms ± 15.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
Idk. Maybe i just dont understand the underlying process of .over(). Feels like it still has potential to do it better in the given example
from polars.
Related Issues (20)
- exception thrown if converting arrow Table with struct and dictionary columns to polar dataframe
- converting pandas to Polars drops column if its name, when converted to string, matches another column's name
- pl.format should be clear it will return null when one of the arguments is null
- Off-by-one error when casting to Decimal with set precision
- Importing pyarrow after polars causes `SIGSEGV` HOT 4
- Polars assumes microseconds instead of reading numpy timedelta units
- Cannot create Array column containing large u64 value
- Multipling a Decimal by Int returns Int type HOT 2
- Split out `Expr.top_k` from `Expr.top_k_by`
- `pl.Datetime` `time_zone` parameter has no type or value check HOT 5
- Cast from `pl.Date` to `pl.Datetime` silently returns incorrect value when new dtype cannot hold value HOT 2
- exception thrown if converting chunked arrow Table with struct and dictionary columns to polar Dataframe
- Panic when constructing Series with dtype `Duration('ms')` with large `timedelta` objects
- Can the separator of the read csv function support regular splitting? HOT 5
- Casting float to Decimal fails silently HOT 2
- Use parquet statistics when collecting column statistics from scanned parquet
- Excessive Memory Consumption During Rolling Operations on Large DataFrames
- write_database() - Insert many rows with sql server using fast_executemany HOT 3
- fill_null doesn't support expr HOT 6
- `dt.total_nanoseconds` and `dt.total_microseconds` may overflow silently
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.