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.
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:
- join my Polars course on Udemy
- follow me on bluesky
- follow me on twitter
- connect with me at linkedin
- check out my youtube videos
or let me know if you would like a Polars workshop for your organisation.