This message was deleted.
# hamilton-help
s
This message was deleted.
👀 1
s
yes - two options. # Option 1: do it in the driver.
Copy code
from non_hamilton_script import historical_dataframe
import transforms # your hamilton functions

dr = driver.Driver({... your  config ...}, transforms)
df = dr.execute([ .... outputs ...], inputs={"historical_dataframe": historical_dataframe})
# Option 2: wrap import in a function with your transforms
Copy code
# transforms.py

def historical_dataframe() -> pd.DataFrame:
    from non_hamilton_script import historical_dataframe
    return historical_dataframe  


def load_data_feed(path: str) -> pd.DataFrame:
    ...
    return df

def complete_dataset(load_data_feed: pd.DataFrame,
                     historical_dataframe: pd.DataFrame) -> pd.DataFrame:
    return pd.concat([historical_dataframe, load_data_feed])
👍 1
s
Thank you. I like the second option since I can't seem to get the first to work. For the future I can see how the inputs argument would be extremely beneficial.
is an empty Driver necessary for this to work?
s
no, let me update the example
s
Copy code
from non_hamilton_script import historical_dataframe
import transforms # your hamilton functions

dr = driver.Driver({... your  config ...}, transforms)
df = dr.execute([ .... outputs ...], inputs={"historical_dataframe": historical_dataframe()})
I believe the
historical_dataframe
needs to be instantiated in the inputs.
when I tried it via Option 1, the below error was thrown. do you have any intuition as to why this could have occured when executing this way?
s
that’s a warning
the error is likely below that
s
yeah actually spyder just decided to break on both executions
s
I believe the
historical_dataframe
needs to be instantiated in the inputs.
yeah if there is a function to exercise, it needs to be run to create the dataframe so it’s passed in.
s
is there any issue with reusing arg name as the new function/column name as below?
Copy code
# transforms.py
def historical_dataframe(historical_dataframe: pd.DataFrame) -> pd.DataFrame:
    return historical_dataframe.rename(columns=columns_mapping)
Does hamilton
dr.execute([], inputs={})
method escalate pandas warnings to errors by chance? Option 1 logic breaks my kernel somehow. Option 2 is still good however.
s
🤔 not sure about the kernel breaking
is there any issue with reusing arg name as the new function/column name as below?
```# transforms.py
def historical_dataframe(historical_dataframe: pd.DataFrame) -> pd.DataFrame:
return historical_dataframe.rename(columns=columns_mapping)```
Yes, this isn’t allowed.
s
maybe this is what is actually breaking it
s
```def historical_dataframe(historical_dataframe_old: pd.DataFrame) -> pd.DataFrame:
return historical_dataframe.rename(columns=columns_mapping)```
just change the parameter name and then the input value accordingly.
s
yes this indirectly i guess fixed the error. option 1 work now.
👍 1