Leanpub Header

Skip to main content

Migrating to Polars 2

What breaks silently between 1.x and 2.0, shown with real runs under both versions

Migrating to Polars 2

Polars 2.0 changed defaults that don't raise errors: lazy queries now stream, and joins no longer keep row order. This short guide shows exactly what breaks when you upgrade from 1.x, with every example run under both 1.44.2 and 2.0.0 and the real output printed side by side.

Minimum price

$12.00

$25.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

You run pip install -U polars on a pipeline that has worked for a year. The tests pass. Then the report comes back with rows in a different order, a join pairs the wrong records, or a nightly CSV import starts failing on a column it used to read.

Polars 2.0.0 shipped on 6 October 2026. Most of its breaking changes are loud: a removed argument raises and names its replacement. The dangerous ones are quiet. The code keeps running, and the result is different.

  • Lazy queries now run on the streaming engine by default.
  • Joins and unpivot no longer come back in input order, and asking for the in-memory engine does not reliably restore it.
  • Integer-versus-float membership checks, signed-plus-unsigned arithmetic, and exploding empty lists now give different answers or raise.
  • Casts that 1.x allowed with a deprecation warning now fail, and some fail only when a row reaches them.
  • CSV reading and schema inference behave differently.

This book walks through those changes area by area and shows each one twice: the same code run under Polars 1.44.2 and under Polars 2.0.0, with the real output from both. No output in the book is invented or retyped. Each output block is a captured run, cited, and the commands are listed so you can reproduce them.

It ends with a migration checklist you can run on your own code:

  1. Pin both versions.
  2. Run your suite on 2.0 with the old engine requested, to surface removals and dtype changes.
  3. Switch to the new default to surface ordering assumptions.
  4. Diff 1.x output against 2.0 output.
  5. Wire the check into CI.

Researched and drafted with AI assistance by Ground Truth Books. Every output shown was produced by real runs, and the text was checked against the official Polars upgrade guide and those captures. "Polars" is used descriptively; this book is not affiliated with or endorsed by Polars Inc.

Author

About the Author

Ground Truth Books

Ground Truth Books publishes practical technical books on computer science, IT tools, data science, machine learning, software engineering and AI.

The name comes from machine learning, where "ground truth" means the real, verified answers you check a model against. That's how these books are made. They're researched and drafted with AI assistance, and then checked against reality. Examples are run against real captures and data in a lab, and those runs are cited like any other source, so you can see which output came straight from the tool. Every claim is cited to its source, with official documentation, specifications and source code preferred over blog posts.

Each book is built around doing the work. Chapters end with exercises, and an appendix gives worked answers you can reproduce on your own machine, using the same freely available data and captures.

Books are updated when the tools change. If you find an error, please report it: a corrected edition is free for every reader, which is one of the best things about Leanpub.

Contents

Table of Contents

About This Book

Introduction

  1. Who this book is for
  2. What changed in 2.0
  3. How the book is organized
  4. How the examples were produced
  5. Part I: The Engine Change

The Streaming Engine Is Now the Default

  1. What engine=‘auto’ resolves to
  2. Eager operations are unaffected
  3. sink_* already streamed
  4. SQL eager=True now streams
  5. Restoring in-memory execution

Row Order Is No Longer Guaranteed

  1. Joins that lose their order
  2. group_by and unpivot ordering
  3. Requesting order explicitly
  4. A left join under both versions
  5. Part II: What Breaks and How to Fix It

Breaking Changes by Area

  1. The guide’s list, sorted by failure mode
  2. concat and union strictness
  3. explode empty_as_null
  4. Int128 supertype and is_in coercion
  5. Output names and Map dtype
  6. Decimal widening, SQL, and Parquet ENUM
  7. Sequencing the audit

Casts and Operations That Now Fail

  1. Casts that now fail
  2. is_in and list.contains comparisons
  3. Operations that now raise
  4. Five more items from the section
  5. Casting examples under both versions
  6. Finding them in your code

API Reshapes, Removals, and Deprecations

  1. API reshapes
  2. Removed APIs and their new errors
  3. New deprecations in 2.0

CSV Reading and Schema Inference

  1. Your CSV imports now run on the lazy reader
  2. read_csv now dispatches to scan_csv
  3. Arguments read_csv lost
  4. schema_overrides and column order
  5. infer_schema_files and counting from zero
  6. raise_if_empty and file column order
  7. Part III: The Migration

A Migration Checklist

  1. Pinning 1.44.2 and 2.0.0
  2. A dual-version test harness
  3. Diffing 1.x and 2.0 outputs
  4. A CI step that runs the diff

Conclusion

  1. What you can now do
  2. Where to go next

Appendix A: Commands used to produce and verify example outputs

  1. The two pinned environments
  2. The lab data
  3. The probe commands
  4. The migrate_check.py harness
  5. The audit commands

Appendix B: Polars 1.44.2 versus 2.0.0 API change table

  1. Scope
  2. Engine and row order
  3. The same line, two versions
  4. Removed APIs and replaced arguments
  5. Casts no longer supported
  6. Loud changes
  7. Silent changes
  8. Deprecations
  9. New exception types

Glossary

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub