class hamilton.plugins.h_polars.PolarsDataFrameResult

A ResultBuilder that produces a polars dataframe.

Use this when you want to create a polars dataframe from the outputs. Caveat: you need to ensure that the length of the outputs is the same, otherwise you will get an error; mixed outputs aren’t that well handled.

To use:

from hamilton import base, driver
from hamilton.plugins import polars_extensions
polars_builder = polars_extensions.PolarsDataFrameResult()
adapter = base.SimplePythonGraphAdapter(polars_builder)
dr =  driver.Driver(config, *modules, adapter=adapter)
df = dr.execute([...], inputs=...)  # returns polars dataframe

Note: this is just a first attempt at something for Polars. Think it should handle more? Come chat/open a PR!

build_result(**outputs: Dict[str, Series | DataFrame | Any]) DataFrame

This is the method that Hamilton will call to build the final result. It will pass in the results of the requested outputs that you passed in to the execute() method.

Note: this function could do smarter things; looking for contributions here!


outputs – The results of the requested outputs.


a polars DataFrame.