11 comments

  • benrutter10 hours ago
    &gt; We don’t aim to make a big feature release of Polars 2.0. In fact we hope it to be a boring experience for you. The reason we bump this major version is that we can get rid of design decisions made in the past that currently block us and then we want to change defaults to more sensible settings that will benefit a greater audience<p>I know this take reveals me as a very dull person, but I <i>love</i> seeing projects take semver seriously like this! Version bumps should really be about removing deprecated cruft rather than shiny new features.<p>I&#x27;ve used polars for a while now, and their focus on stability was a big part if convincing me to make the jump initially!
    • altern87 hours ago
      Aren&#x27;t major versions supposed to indicate breaking changes..?<p>That&#x27;s how I thought semantic versioning worked
      • theptip3 hours ago
        Concretely, TFA lists a bunch of input validation that is being made more strict in the default configuration.
      • suddenlybananas7 hours ago
        &gt;The reason we bump this major version is that we can get rid of design decisions made in the past that currently block us and then we want to change defaults to more sensible settings that will benefit a greater audience<p>I don&#x27;t know how to read this sentence other than &quot;there are breaking changes we want to make&quot;
        • magicmicah856 hours ago
          The migration guide does say there are breaking changes, but the interpretation I have is &quot;this won&#x27;t have new features but allows us to develop new features&quot;.
        • altern87 hours ago
          I see. Just making sure I had it right :-)
      • cassianoleal6 hours ago
        Not every product uses SemVer
        • winniewinnie6 hours ago
          But Polars does:<p><a href="https:&#x2F;&#x2F;docs.pola.rs&#x2F;development&#x2F;versioning&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.pola.rs&#x2F;development&#x2F;versioning&#x2F;</a><p>&gt; Polars adheres to the semantic versioning specification:<p>And it does have breaking changes in 2.0. The original asker presumably missed that.<p>E:<p>On the other hand, that whole page on versioning seems inconsistent.
    • nicce9 hours ago
      &gt; Version bumps should really be about removing deprecated cruft rather than shiny new features.<p>Can there be deprecated cruft without new features? :-D
      • kvdveer8 hours ago
        Ideally: no.<p>All new shiny new features shouldn&#x27;t have waited for the (N+1).0 version, they should already have been part of the (N).(M) version.<p>In practice, the removing the deprecated cruft will remove blockers for some new features, but that should be rare.
      • SkiFire137 hours ago
        Yes, the features don&#x27;t need to be added immediately.
    • dist-epoch9 hours ago
      That being said Polars is one of the few Python libraries from the hundreds I use that I need to read the notes of every minor release (eg 1.44 -&gt; 1.45), because they tend to frequently deprecate, remove or change features.
      • duskdozer7 hours ago
        It sounds like they should be on a version much higher than 2.x then.
        • sanderjd4 hours ago
          Deprecating without breaking is fine in a minor version under semver.
          • tialaramex1 hour ago
            There&#x27;s also always a &quot;strictness&quot; curve. Rust has specific rules where you could write something which doesn&#x27;t break those rules but does break people who&#x27;ve done something very specific<p>At some point you reach the Hyrum&#x27;s Law &#x2F; Spacebar Heating edge where sure, there&#x27;s no reasonable technical definition which concludes your change &quot;broke&quot; people but somebody&#x27;s solution used to work and now it doesn&#x27;t and they&#x27;re angry about that.<p>To give an example that&#x27;s only <i>slightly</i> less ridiculous than spacebar heating, maybe somebody depended on being able to parse a file from your library, you re-designed the library, there are no API changes but they&#x27;re <i>parsing your source code</i> and now their approach doesn&#x27;t work.<p>Generally, libraries with fewer and lighter users tend to be more lax, maybe they forgot to make a structure opaque, that&#x27;s a break but none of their users notice, or they forgot to make an error type non-exhaustive, but everybody using their type had a default clause so no harm done when they add a new value.<p>Hyrum means that as you get bigger and more important, some day, the spacebar heating problem happens and too bad. A language (like Rust) can help you forestall that day somewhat, and reduce the blast radius when it does, but it is inevitable, Hyrum&#x27;s law wasn&#x27;t something you can outright prevent from happening, it&#x27;s a factor for engineers to consider when designing systems, like misuse resistance.
          • 0x45728 minutes ago
            Did you miss &quot;remove or change features.&quot; ?
    • Bluestein10 hours ago
      &quot;Tranquil development&quot; (vs. &quot;hype-driven shipping&quot;) :)
  • perrygeo4 hours ago
    For me, the superpower of polars is production stability.<p>Pandas tends to push all problems to runtime, with all sorts of hidden heuristics. Particularly around column types and missing values. It&#x27;s very hard to know if you&#x27;ve tested all the edge cases. The only way to test your code is to throw all variations of data at it. Fine if you&#x27;re sitting at a notebook and have the patience to validate and &quot;clean&quot; the data on its behalf. Not so fine if you get paged at 3am because your data pipeline failed when it expected an int column but got float.<p>Polars is more strict by default and front-loads costs through its planner. The resulting apps are noticeably more stable in production. You can test code and reasonable assurance that it will work on data in the wild.<p>I don&#x27;t really have any interest in the API ergonomics or syntax - both are fine. It&#x27;s all about how they deal with data variation at runtime. Can you write general code that doesn&#x27;t break on variants? Pandas, not a chance. Polars, absolutely!<p>Bonus round: polars has a Rust API too, the compiler can effectively prove that your program handles <i>every</i> edge case. It&#x27;s common to write rust polars apps that run unattended for years.
    • sigseg1v4 hours ago
      Do people actually use languages where it doesn&#x27;t do any compile time checks on the API in 2026? Why would developers put up with the lack of that. I&#x27;m not in this ecosystem but what you are describing sounds like the bare minimum to me that should be table stakes.
      • perrygeo3 hours ago
        I agree. But the data science&#x2F;engineering space is enamored with Python. Makes good sense when doing interactive work. Makes no sense in production. But by that point, most developers consider it a sunk cost and just keep their Python apps limping along rather than rewriting.<p>That&#x27;s why polars is a great option. Start prototyping in python, then a relatively easy port to a Rust app when the need hits.
        • maleldil3 hours ago
          You can still have extensive &quot;compile-time&quot; checking with linters and static type checkers. This makes Polars even better in typed Python, as it type-checks much better than the dynamic mess that is Pandas.
          • perrygeo3 hours ago
            Polars is <i>much</i> better than pandas in this regard. But using it via Python still carries the risk of runtime errors.<p>Python&#x27;s linters leave many holes unfilled - it catches some stuff but still leaves everything else to the runtime. Literally every Python application that I&#x27;ve worked on in the last 3 years a) is 100% type checked yet b) still hits massive numbers of novel runtime errors on the regular. Python&#x27;s anemic type system is in no way a substitute for an advanced compiler.
  • trombonechamp7 hours ago
    Is there a reason besides performance that maintain_order=False by default? I ask because polars is used in many scientific data analysis pipelines, and non-deterministic behaviour is a well-documented source of bugs in scientific computing (e.g. <a href="https:&#x2F;&#x2F;pmc.ncbi.nlm.nih.gov&#x2F;articles&#x2F;PMC6919963&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pmc.ncbi.nlm.nih.gov&#x2F;articles&#x2F;PMC6919963&#x2F;</a>). The new default requires users to keep the implementation details of the API in their head while determining whether code is correct or not. This is tricky with scientific computing because the correct answer is not known in advance, so bugs can slide by and silently give incorrect results.
    • hopfenspergerj6 hours ago
      It&#x27;s standard sql behavior, users always specify the ordering they want as part of the query.
      • Xunjin3 hours ago
        Often people new to databases and SQL thinks ordering is implicit, I have teach dozens of juniors that believe this is the default. I always wondered why that is the thought process...
        • fwip3 hours ago
          Because out of the first 100 queries they ran, 99 came back in order and they didn&#x27;t notice that the 100th didn&#x27;t.
    • dash23 hours ago
      I once persuaded the dplyr maintainers not to do an update that might re-order rows after a filter(). I think the human tendency to think of database rows as existing in a fixed, given order, which will only be changed explicitly, is deep.
    • nemothekid4 hours ago
      If the correctness of my program depends on the ordering of data (for operations that would otherwise be commutative), that seems like that should be something explicit rather than implicit.<p>I&#x27;m not sure if I agree that &quot;hidden setting actually keeps your data correct&quot; is something that should be the default.
    • Permik5 hours ago
      This is a tricky field, the problem is not actually the non-determinism of the processing algorithms, but implicit ordering of the data.[1] The implicit ordering of the data is a footgun that -- as seen in the paper -- has already claimed victims. Using algorithms that don&#x27;t need to upkeep the ordinality requirement in every operation will definitely move the library to a better direction and make future data modeling better and more explicit.<p>[1] Aha, now I see why language models use this so frequently and why it might be overrepresented in the data. This is a perfect way to move the blame from the person you&#x27;re responding to, if they&#x27;re mistaken. They probably have a super, super overtuned &quot;politeness&quot; gym using sentiment analysis that tries to reword answers to not blame the misunderstandings of the person. Then this blame shifting unfortunately gets re-used as this super, super common phrase.
      • winniewinnie5 hours ago
        By &quot;implicit ordering&quot;, do you mean &quot;implicitly assumed that the data is ordered a certain way&quot;? Since if that assumption of data being sorted a certain way is broken on some systems and not others, the result might be both non-deterministic (which could be a bug if the result is not allowed to be non-deterministic, but may or may not be a bug regarding the algorithm&#x27;s assumptions) as well as a bug if the algorithm&#x27;s assumptions requires it to be sorted a certain way.<p>&gt; Using algorithms that don&#x27;t need to upkeep the ordinality requirement in every operation will definitely move the library to a better direction and make future data modeling better and more explicit.<p>How would the library &quot;make future data modeling ... more explicit&quot; if this is a change to a default, which is implicit?
        • Lvl999Noob2 hours ago
          &gt; How would the library &quot;make future data modeling ... more explicit&quot; if this is a change to a default, which is implicit?<p>It would become more explicit because where the order matters, you will now see a `maintain_order=True` where previously, you couldn&#x27;t say whether it actually needed the fixed order or not.
    • sanderjd4 hours ago
      Is &quot;non-deterministic&quot; the right description for this? I read it as describing an implementation where ordering is not preserved, but deterministically. Is that a misreading?
      • dhampi3 hours ago
        For example, polars internally hashes rows for some operations in ways that affect the ultimate ordering.<p>They do not guarantee stability of hashing algorithm or seed across versions and platforms.<p>(No complaints here! I agree ordering shouldn’t matter unless you make it explicit.)
    • 0cf8612b2e1e4 hours ago
      This behavior has repeatedly frustrated me. I am writing some new transformation, want to see the results, and my first few sentinel rows are nowhere to be seen because they have been shuffled.<p>I do not think of a dataframe as a set, but an ordered collection of rows. My source csv had the rows in this order and I want that maintained unless I choose maximum performance.
      • geysersam56 minutes ago
        Why not slap an order_by on the end of the query and you&#x27;re all good? If that&#x27;s expensive maybe you can add a limit clause to your source.
        • 0cf8612b2e1e15 minutes ago
          Sure, I can change what I get, I just disagree that my ordered table is not guaranteed to stay ordered.<p>Neither R nor Pandas will shuffle results by default.
    • winniewinnie6 hours ago
      Perhaps to get better results on benchmarks.
      • Bootvis5 hours ago
        Or you know, just better performance for people that know how to use their tool of choice.
        • winniewinnie5 hours ago
          Wouldn&#x27;t such people just pass in<p><pre><code> maintain_order=False ?</code></pre>
          • Bootvis5 hours ago
            That’s an API design question. What is the more common use case.<p>You seem to suggest they did it for benchmarking reasons only. They could use the option there themselves without changing the default so that is unlikely to be the motivation.
  • lmeyerov5 hours ago
    Moving towards streaming and generally out-of-core is great<p>We recently added a Polars backend to GFQL (cypher graph queries on dataframes, no DB needed), both CPU and GPU mode, and super impressive. Noticeable improvements vs pandas&#x2F;cudf, and enabled GFQL to beat out popular systems on more categories like low-latency, not just big datasets: <a href="https:&#x2F;&#x2F;www.graphistry.com&#x2F;blog&#x2F;cypher-on-polars-cpu-gpu-graph-engine" rel="nofollow">https:&#x2F;&#x2F;www.graphistry.com&#x2F;blog&#x2F;cypher-on-polars-cpu-gpu-gra...</a>
  • bobson_dugnutt510 hours ago
    I love polars. Did a lot of evangelizing in work to get people to give up pandas in favor of it.
    • anotherpaul9 hours ago
      I gave up pandas in favor of polars after someone at work did the same and I am very happy with it. Pandas API is just so much worse and much slower.
      • winniewinnie6 hours ago
        Have Polars&#x27; inconsistent versioning policy caused you any problems?
    • duskdozer7 hours ago
      I guess I am a casual pandas user only. Reading a guide on migrating&#x2F;differences, it&#x27;s hard to see why polars would be obviously better.
      • bobson_dugnutt57 hours ago
        Here are a couple reasons:<p>- much faster, multithreaded by default. Read in a big csv with it and see how it feels.<p>- no index&#x2F;MultiIndex. Pandas special treatment of index always felt like more trouble than it was worth, so no need to reset_index() everywhere.<p>- expressions are very portable. At first using pl.col everywhere feels like a bit much, but you can define them anywhere and then apply them to a dataframe whenever you want.<p>- once internalized, the syntax makes much more sense and is far more consistent compared to pandas.<p>Of course all depends on what your use cases are. If performance is important then I&#x27;d strongly recommend trying it out. If you just use it to have a look at the odd dataframe, maybe not worth your time as much
      • 0cf8612b2e1e3 hours ago
        End of the day, they both get the job done.<p>Pandas is more ergonomic in that some ideas can be more tersely represented. The downside is that this results in more dynamism which can change if the underlying data gets updated. Polars is more strict in that it will not silently flip a data type on you. However this strictness does come at the cost of being a bit slower to type and some data idioms not having a good Polars equivalent.<p>People like to note the speed improvements, but that is the least interesting thing about the library. Rarely have I ever had a problem where I was bottlenecked by Pandas throughout.<p>Polars is very much a Pandas 2.0 with a bunch of lessons learned. I do not think it is earth shattering changes, but it is worth migrating when you can.
    • latexr7 hours ago
      Taken out of context, your post looks like a conservationist who got fed up with pandas being a flagship species and made it their lifelong mission to replace them with polar bears.<p>This is not a criticism. As someone who doesn’t use Python, I simply found it amusing.
      • bobson_dugnutt514 minutes ago
        Thank you, your the only person to correctly interpret my comment :)
      • blitzar7 hours ago
        You should learn Boa constrictor instead of Python.
    • mgaunard9 hours ago
      Both have terrible syntax that make SQL look like the most readable thing ever.
      • condwanaland9 hours ago
        Could not agree less. Ive always found SQL an unreadable mess but tools like polars and dplyr are such elegant ways to manipulate data.<p>Pandas is a mess though.
        • world2vec8 hours ago
          There&#x27;s no way SQL is more unreadable than polars. IMO it&#x27;s the other way around.
          • benrutter8 hours ago
            &gt; There&#x27;s no way SQL is more unreadable than polars. IMO it&#x27;s the other way around.<p>I think on basic queries, SQL is really nice, but when stuff gets more complex, with a bunch of CTEs, let alone functions requiring loops, it becomes pretty obtuse.
          • sanderjd4 hours ago
            I would say that it is easier to decompose polars (and all dataframe api) queries and to build them up from pieces than it is to do the same with sql. Any time I find myself writing more than five or so lines of sql, or especially building a sql string in parts with logic, I wish I had a dataframe api instead. But the reverse is also somewhat true, that simpler and explicit expressions are nicer with sql.
      • aquafox9 hours ago
        Coming from an R&#x2F;dplyr background, I agree. Compare<p>df.select(<p><pre><code> pl.col(&quot;x&quot;), (pl.col(&quot;w&quot;)&#x2F;pl.col(&quot;z&quot;)).alias(&quot;y&quot;) </code></pre> )<p>with<p>df |&gt; select(x, y = w&#x2F;z)
        • orlp8 hours ago
          <p><pre><code> from polars import col as C df.select(C.x, y = C.w &#x2F; C.z)</code></pre>
          • dkga7 hours ago
            Still, it’s a very good approximation but still an approximation to the more ergonomic and expressive tidyverse syntax
            • sanderjd4 hours ago
              One person&#x27;s &quot;ergonomic and expressive&quot; is another person&#x27;s &quot;wait what in the world is actually going on here&quot;.
          • __mharrison__5 hours ago
            This is the way. Favor keyword arguments to alias.
        • jcattle8 hours ago
          R really is&#x2F;was the superior traditional data science language. Python ecosystem is slowly catching up though.<p>ggplot vs matplotlib<p>dplyr vs pandas<p>And I loved that everything in RStudio was so easily inspectable. Have a huge dataframe? Just look at it right in your IDE.
          • vovavili8 hours ago
            Altair and Positron should be just as good for your Polars @ Python needs. With software like Marimo notebooks and VegaFusion, Polars&#x2F;Python experience starts beating R by quite a substantial margin.
        • bobson_dugnutt59 hours ago
          Fair point, but you can do something like<p>`df.select(&quot;x&quot;, y=pl.col.w&#x2F;pl.col.z)`
        • sanderjd4 hours ago
          To me, I immediately wonder whether w, x, y, and z here are variables or column names. It would indeed be nice if python could more tersely represent the distinction between a name and a literal string (or worse, as in your R example, a variable reference), but alas. But I think trading some verbosity for explicitness about this distinction is a pretty good trade, and very in keeping with python style.
        • countrymile6 hours ago
          Polars is a world away from pandas, but I feel that dplyr still offers the most simple and understandable introduction to data analysis for the beginner. The above is a good example of this.
      • geysersam7 hours ago
        I agree sql is more elegant. The problems arise when you have to add logic on top of sql. Often I end up constructing queries via string manipulation and that is not very ergonomic. Polars api is more verbose and complex than sql but at least it&#x27;s not meta-programming.<p>The duckdb python api is okay, but it is a bit limited, no ctes, no as of join, and it can be slow at bind&#x2F;interpretation time when you do stuff like unioning multiple relations in a loop (I think that becomes O(N^2), but I might be wrong). Most issues can be worked around, but Polars is designed from the ground up to be used from python.
        • vovavili6 hours ago
          You should be using dbt instead of string manipulation for serious query building.
          • sanderjd4 hours ago
            It&#x27;s never quite been clear to me what the advantage of dbt over a python program using sqlalchemy &#x2F; duckdb &#x2F; polars to transform data is. Can you enlighten me?
            • vovavili3 hours ago
              At the minimum, it&#x27;s just Jinja2 templates in your SQL queries - meaning, you can do pure SQL transformations with conditional logic in your templates. In addition to being able to run tests, specify custom macros, having version control and having some constrained way to organize your tables, you&#x27;re turning SQL into a proper programming language with just one library.
              • throwaway778314 minutes ago
                My issue with DBT is it is a mix of SQL, yaml, jinja2 flow controls (and metrics is whole another thing). SQL with jinja2 if&#x2F;else can get really unmaintainable quickly. It&#x27;s perhaps better than homegrown sql based transformers.<p>polars is code and can be version controlled too. Dataframes in my opinion are more elegant, and with the right backends and some lineage enhancements, could serve a much wider set of use cases than what DBT does
                • vovavili7 minutes ago
                  Different tools for different tasks.
          • geysersam3 hours ago
            I&#x27;ve been looking at dbt for exactly this reason but don&#x27;t quite get the advantages if you&#x27;re not interacting with a data warehouse of some sort.
            • vovavili2 hours ago
              Embedded databases like DuckDB are just as suited for dbt work.
      • bobson_dugnutt59 hours ago
        What is it about polars syntax you don&#x27;t like? The fact that is very verbose? At first I wasn&#x27;t a fan, but over time I&#x27;ve grown to really like it. That never happened to me with pandas, always felt the syntax was messy
        • mihaelm7 hours ago
          The verbosity takes a bit to get used too, but it sure beats the anything-goes feeling - messy as you put it - of pandas.
      • gpugreg8 hours ago
        You can query polars data frames with SQL: <a href="https:&#x2F;&#x2F;docs.pola.rs&#x2F;api&#x2F;python&#x2F;stable&#x2F;reference&#x2F;expressions&#x2F;api&#x2F;polars.sql.html" rel="nofollow">https:&#x2F;&#x2F;docs.pola.rs&#x2F;api&#x2F;python&#x2F;stable&#x2F;reference&#x2F;expressions...</a><p>Unfortunately, polars does not support parameterized queries, so the risk of SQL injection is extremely high.
      • fzumstein9 hours ago
        I tend to agree. SQL may have been harder to write in the past (worse autocomplete than pandas&#x2F;polars), but now that AI is writing the code, SQL is usually much easier to read. So DuckDB is another interesting alternative to pandas.
        • refactor_master9 hours ago
          The cool thing about polars is that you can conditionally collect expressions over many layers of business logic, and then compute the result at the end. Doing this in SQL ends up in a hodgepodge of strings and trimmed ends to please the syntax. You can also pretty effortlessly write quite complex conditionals directly in polars, and bridge it easily to the surrounding python.<p>I find that SQL is only easier to read with minimal abstraction, but as soon as the project gets bigger SQL becomes an unwieldy island of <i>different</i> that has served its purpose after we’re done with reading&#x2F;writing the data.
          • fzumstein8 hours ago
            This sounds interesting! Do you have a specific example by any chance or blog post&#x2F;doc references?
            • refactor_master8 hours ago
              It’s just the lazy&#x2F;expression part of the API, which is really the bread and butter of polars, rather than just being “replacement syntax” for pandas. This allows you to tap into abstraction that SQL can’t keep up with:<p><pre><code> import polars as pl # 1. Base Dataset lazy_df = pl.LazyFrame( { &quot;store_id&quot;: [&quot;S01&quot;, &quot;S02&quot;, &quot;S03&quot;, &quot;S04&quot;, &quot;S05&quot;], &quot;revenue&quot;: [5000.0, 2400.0, 15000.0, 900.0, 3200.0], &quot;margin&quot;: [0.45, 0.30, 0.60, 0.15, 0.50], &quot;tx_count&quot;: [120, 45, 300, 20, 85], &quot;returns&quot;: [5, 12, 45, 2, 8], } ) # 2. Define Layer Abstractions def get_kpi_layer() -&gt; list[pl.Expr]: return [ (pl.col(&quot;returns&quot;) &#x2F; pl.col(&quot;tx_count&quot;)).alias(&quot;return_rate&quot;), (pl.col(&quot;revenue&quot;) &#x2F; pl.col(&quot;tx_count&quot;)).alias(&quot;avg_order_value&quot;), ] def get_threshold_layer(thresholds: dict[str, list[float]]) -&gt; list[pl.Expr]: return [ (pl.col(col) &gt; limit).alias(f&quot;is_{col}above{int(limit)}&quot;) for col, limits in thresholds.items() for limit in limits ] def get_interaction_layer(numeric_cols: list[str]) -&gt; list[pl.Expr]: return [ (pl.col(a) &#x2F; (pl.col(b) + 1e-5)).alias(f&quot;ratio_{a}per{b}&quot;) for i, a in enumerate(numeric_cols) for b in numeric_cols[i + 1 :] ] def get_segmentation_layer() -&gt; list[pl.Expr]: return [ pl.when(pl.col(&quot;margin&quot;) &gt; 0.4) .then(pl.literal(&quot;High&quot;)) .otherwise(pl.literal(&quot;Low&quot;)) .alias(&quot;margin_profile&quot;) ] # 3. Consolidate and Execute Single Graph Pass thresholds = {&quot;revenue&quot;: [1000.0, 5000.0, 10000.0], &quot;tx_count&quot;: [50, 100, 200]} numeric_cols = [&quot;revenue&quot;, &quot;margin&quot;, &quot;tx_count&quot;, &quot;returns&quot;] expr_pool = [ *get_kpi_layer(), *get_threshold_layer(thresholds), *get_interaction_layer(numeric_cols), *get_segmentation_layer(), ] final_df = lazy_df.with_columns(expr_pool).collect()</code></pre>
              • fzumstein6 hours ago
                awesome, thanks!
              • _zoltan_7 hours ago
                I&#x27;m sorry but this looks much better:<p><pre><code> WITH raw_data AS ( SELECT * FROM ( VALUES (&#x27;S01&#x27;, 5000.0, 0.45, 120, 5), (&#x27;S02&#x27;, 2400.0, 0.30, 45, 12), (&#x27;S03&#x27;, 15000.0, 0.60, 300, 45), (&#x27;S04&#x27;, 900.0, 0.15, 20, 2), (&#x27;S05&#x27;, 3200.0, 0.50, 85, 8) ) AS t(store_id, revenue, margin, tx_count, returns)), base_data AS ( SELECT store_id, revenue, margin, CAST(tx_count AS DOUBLE) AS tx_count, CAST(returns AS DOUBLE) AS returns FROM raw_data ) SELECT store_id, revenue, margin, CAST(tx_count AS BIGINT) AS tx_count, CAST(returns AS BIGINT) AS returns, -- KPI Layer returns &#x2F; tx_count AS return_rate, revenue &#x2F; tx_count AS avg_order_value, -- Threshold Layer (matching original alias names) revenue &gt; 1000.0 AS is_revenueabove1000, revenue &gt; 5000.0 AS is_revenueabove5000, revenue &gt; 10000.0 AS is_revenueabove10000, tx_count &gt; 50 AS is_tx_countabove50, tx_count &gt; 100 AS is_tx_countabove100, tx_count &gt; 200 AS is_tx_countabove200, -- Interaction Layer (preserving exact numeric formula &amp; aliases) revenue &#x2F; (margin + 1e-5) AS ratio_revenuepermargin, revenue &#x2F; (tx_count + 1e-5) AS ratio_revenuepertx_count, revenue &#x2F; (returns + 1e-5) AS ratio_revenueperreturns, margin &#x2F; (tx_count + 1e-5) AS ratio_marginpertx_count, margin &#x2F; (returns + 1e-5) AS ratio_marginperreturns, tx_count &#x2F; (returns + 1e-5) AS ratio_tx_countperreturns, -- Segmentation Layer CASE WHEN margin &gt; 0.4 THEN &#x27;High&#x27; ELSE &#x27;Low&#x27; END AS margin_profile FROM base_data;</code></pre>
                • throwaway77839 minutes ago
                  Well, I prefer the polars version. And now if I want to reuse the CTEs elsewhere, I have to reach out to another tool like DBT or hand roll something to do string manipulation.
                • sanderjd4 hours ago
                  ... does it? I don&#x27;t think it does, even in this form.<p>And now write it such that all the conditions and transformations are injected into the string (somehow) rather than written in explicitly. Much worse.
                • bobson_dugnutt53 hours ago
                  Really? You&#x27;ve written out all the ratios and thresholds manually. If a user wanted to change the set of thresholds the polars way is far superior. In what way do you consider this better?
  • Kydlaw8 hours ago
    Happy to see activity around Polars. This has been my go-to library for data processing due to the enhanced ergonomics compared to Pandas and SQL.<p>But they were a bit quiet lately, and I started looking more and more into DuckDB recently… until the recent acquisition of DuckLab by AWS
    • f311a7 hours ago
      I&#x27;ve been using clickhouse-local for quite some time, instead of DuckDB. There is also chDB.<p>After using pandas for 10 years, I favor SQL now, for some reason.
      • geysersam53 minutes ago
        Interesting, why do you typically prefer clickhouse local to duckdb?
      • Kydlaw3 hours ago
        I haven&#x27;t tried chDB yet, but I heard about it. Thank you for reminding me of that option.<p>I use SQL in data pipelines and processing that is going to require interoperability.<p>But for data exploration, I usually prefer Polars (imo it is easier to work with text, semi-structured data, etc.)
      • mihaelm7 hours ago
        Maybe because it&#x27;s like a swiss army knife for data work, regardless of whether you need it for OLTP or OLAP workloads. Having different SQL dialects is a bit annoying, but the base is the same more or less, so switching doesn&#x27;t come at too big of a cost.
      • efromvt7 hours ago
        As a huge duckdb fan, I&#x27;d love to see chDB to get proper windows support - that would make it real competition (having WASM coverage is already a big step) which would be good for the space as a whole.
  • bbstats3 hours ago
    Bothering me like crazy that &quot;Use instead: .cat.to(dtype) for int → categorical, .cat.physical() for categorical → int.&quot; doesn&#x27;t give the requisite code example!
  • arn3n8 hours ago
    The decision to default to the streaming engine is really interesting. My intuition is that this would be slower than other data frame operations that are more parallelizable with batch processing, because streaming engines necessarily process rows sequentially. Is my intuition off&#x2F;am I overestimating how much auto-parallelization polars does?
    • orlp8 hours ago
      Streaming here has a different meaning than perhaps what you&#x27;re used to. It&#x27;s not referring to online processing where you maintain aggregates&#x2F;state while an endless stream of data comes in.<p>The name was chosen early on to contrast with the old execution model, which was essentially all-data-in-memory, column-at-a-time. That engine still exists, we use it as a fallback mechanism for things that aren&#x27;t supported yet in the new engine (or if you explicitly ask for `engine=&quot;in-memory&quot;`).<p>The new execution model first constructs a computational graph of nodes which communicate in streams of in-cache batches (morsels) of data, meaning the full dataset will never be held in memory if not necessary. This was called the streaming engine for that reason in an early prototype and the name stuck. In hindsight I do admit the naming choice is somewhat confusing.
      • sanderjd4 hours ago
        When you say &quot;in-cache batches&quot;, you mean that this cache is on disk? Is that only the case when data is quite large?<p>(Or a more general question: What is the best resource for me to read about how the streaming engine and cache work?)
        • orlp4 hours ago
          Well... once my recent work on out-of-core lands the batch <i>could</i> be on disk when we run out of memory budget ;)<p>But no, that&#x27;s not what I meant. I meant that the batch is meant to be of a size that fits in your CPU cache. This can be a huge throughput improvement as each bit of data stays in cache as it moves from data source to sink.<p>Compare this to column-at-a-time execution: by the time you start the next operation on this column the start of the column will be out of cache again, meaning you operate at RAM speed (or worse, disk speed) rather than cache speed.<p>I gave a (fairly surface-level) talk on the streaming engine a bit over a year ago: <a href="https:&#x2F;&#x2F;pola.rs&#x2F;posts&#x2F;talk-polars-meetup-1-streaming-engine&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pola.rs&#x2F;posts&#x2F;talk-polars-meetup-1-streaming-engine&#x2F;</a>.
      • arn3n8 hours ago
        Cool, thanks for the explanation!
  • rfgplk10 hours ago
    [flagged]
    • thibaut_barrere9 hours ago
      I like when large projects do that. This gives leeway for sister projects (eg wrappers) to anticipate, room for apps that use it intensively to test things out (release candidate etc), something which has really helped me in the past.<p>In that specific case I use a Polars wrapper in Elixir (called Explorer) all week long, and I am very happy they are giving us early hints.
      • rfgplk6 hours ago
        I was referring to the &quot;land&quot; verb choice, aka a clear Claudism. In fact looking at it more carefully, the whole post seems to be heavily AI written with minimal human intervention.
        • Philpax5 hours ago
          Actually, I would say the exact opposite. This post is full of strange and grammatically incorrect phrases, weird paragraph pacing, and unintuitive clauses: that is to say, this reads as very strongly human-written to me, and it is refreshing.
    • marliechiller9 hours ago
      What is your understanding of a Pre-Release then?
    • dbdr10 hours ago
      Why?
      • irpap9 hours ago
        I assume because “land” is a word Claude would choose.
        • mgaunard9 hours ago
          Claude&#x27;s wording (and knowledge) is based on what competent senior engineers would say.
          • blitzar7 hours ago
            I really hope I don&#x27;t have to work with these &quot;competent senior engineers&quot; anytime soon — my codebase couldn&#x27;t handle it.<p>On the plus side I would spend all day hearing I am &quot;absolutely right&quot; from a superior being.
          • tecleandor9 hours ago
            None of the competent senior engineers I know say &quot;not this, but that&quot; every two sentences.
            • pepperoni_pizza7 hours ago
              But what about load-bearing seams that have provenance?
        • tancop9 hours ago
          It&#x27;s the <i>only</i> good word here. &quot;Drop&quot; can also mean the opposite and anything else sounds too formal. Don&#x27;t get me started on &quot;release will release&quot;.
          • gjm117 hours ago
            Well, they could have written something like &quot;The 2.0 release itself will be in the next few weeks&quot; or &quot;It will be a few weeks before the actual 2.0 release&quot;.<p>(But I agree that &quot;land&quot; is fine here, and the rest of TFA doesn&#x27;t strike me as obviously AI-written. And I&#x27;m not a fan of the &quot;look, they did one thing that AIs often do! Must be AI and therefore bad!&quot; thing in any case.)
          • rfgplk6 hours ago
            &quot;Polars 2.0 will be released (publicly) in the following weeks&quot; sounds far more natural.
      • rfgplk6 hours ago
        Clear Claudism. It wants to &quot;land&quot; everything, everywhere.
    • NSPG9118 hours ago
      release will be [released] in the following weeks
  • luciana1u7 hours ago
    every major version of polars is a reminder that the API you finally memorized was always just a suggestion
  • bluebarbet8 hours ago
    What does this project have to do with Serbia? Are the developers in Belgrade?
    • mkl7 hours ago
      It&#x27;s just a play on the name, and it&#x27;s pretty common. claude.ai has nothing to do with Anguilla, John Romero&#x27;s rome.ro has nothing to do with Romania, twitch.tv has nothing to do with Tuvalu, etc.
      • bluebarbet7 hours ago
        Indeed, and Bit.ly has nothing to do with Libya, nor Lemmy.ml with Mali (both failed states). I posit that domain hacking is an ugly, shortsighted, unserious habit that we should drop.