Home Inspecting a Polars query
Post
Cancel

Inspecting a Polars query

This post was created while writing my Up & Running with Polars course. Check it out here with a free preview of the first chapters

A great feature of Polars is its query optimiser that can look at your full set of operations for any potential efficiencies. But what if you want to see what’s happening at some intermediate point in the query?

In this case we can add a call to .inspect in our query. This prints the dataframe at that node in the optimised query graph.

We see this in the example below where we do a filter before doing a groupby. By adding inspect between filter and groupby we can print the output at that point in the query. Inspecting a Polars query

This can be very helpful when debugging complex queries!

Learn more

Want to know more about Polars for high performance data science and ML? Then you can:

or let me know if you would like a Polars workshop for your organisation.

This post is licensed under CC BY 4.0 by the author.