I'm slowly porting an existing codebase to Hamilto...
# hamilton-help
b
I'm slowly porting an existing codebase to Hamilton and I'm trying to access the result of one of the workflow step. The result is a DataFrame. I made a function to return it (and called from the execute()) but when I access it from the execute function, each column is a key in the result dictionary. Is there a way to not have hamilton deconstruct the dataframe in the result?
t
If you have a code snippet that could help. If I understand, you have
Copy code
from hamilton.driver import Builder

dr = Builder().with_modules(...).build()

# returns a dictionary with keys `series_a` and `series_b`
results = dr.execute(["series_a", "series_b"])
and
results
is a dictionary of
pd.Series
## Solution By default,
Driver.execute()
returns a
dict
. Using a
ResultBuilder
, you can automatically merge the series to return a DataFrame.
Copy code
from hamilton.driver import Builder
from hamilton.base import PandasDataFrameResult

dr = (
  Builder()
  .with_modules(...)
  .with_adapters(PandasDataFrameResult())
  .build()
)

# returns a dataframe with two columns
results = dr.execute(["series_a", "series_b"])
b
While making a simple proof of concept code I realized that it was
.with_adapters(base.PandasDataFrameResult())
that created the problem for me, removing the line fix the behavior. Sorry about that
👍 1