Hi guys, I am trying to figure out, how to do the...
# hamilton-help
v
Hi guys, I am trying to figure out, how to do the following: I fetch some data from an RestAPI for two assets. In a second step, I need to join the fetched dataframes. I´d like to use one (parameterized) function for the download and one function to join both datasets. However, I get the following error:
Copy code
InvalidDecoratorException: Expected a single node to transform, but got 2. <class
'hamilton.function_modifiers.expanders.extract_columns'>  can only operate on a single node, but multiple nodes were
created by df_raw
Here is a simple toy example:
Copy code
@extract_columns("col1", "col2", "key")
@parameterize(
    api_data_1=dict(asset_id=value("123abc"),
    api_data_2=dict(asset_id=value("321cba")
)
def api_data(asset_id=str)->pd.DataFrame:
    return my_data_fetcher(asset_id=asset_id)

def joined_data(api_data_1:pd.DataFrame, api_data_2:pd.DataFrame)->pd.DataFrame:
    return api_data_1.join(api_data_2, on="key")
I think the problem is related to the @extract_columns + @parameterize. Is there a work around, or should place the column selection into the function and skip the usage of @extract_columns?
e
Hey! So we have https://hamilton.dagworks.io/en/latest/reference/decorators/parameterize_extract_columns/ which I think should be exactly what you’re looking for :)
That said, I think it’s also valid to not use extract_columns, considering you join on the dataframe (not the columns), if I read right
v
Many thanks!