This message was deleted.
# hamilton-help
s
This message was deleted.
🎉 1
👀 1
s
@Seth Stokes where should:
Copy code
INTBAL: pd.Series, ITURN: pd.Series,
                    YEAR: pd.Series, DAYS: pd.Series
come from?
load_tbl_interest
or
interest_spread_by_month
?
Hamilton doesn’t know how to connect the inputs required to produce a result.
Also with:
return load_tbl_interest.groupby([‘INTERESTMONTH’])[interest_spread].sum()
Can you help me understand the intended output here? It seems like you’re referencing the
interest_spread
function?
s
load_tbl_interest
Yes I didn’t know if I can reference the function or will I have to hard code the string of the column name from that function
s
do you mind sketching out the schema (i.e. columns) of the dataframe you want?
s
Yes let me walk back to the office
s
no hurry 🙂
s
['INTERESTMONTH', 'INTBAL', 'TYPE', ACCOUNT', 'IRATE', 'ITURN', 'YEAR', 'CCY', 'MARKET', DAYS']
these are from the loaded table
s
cool. What should be the dataframe produced by
interest_spread_by_month
?
s
correct
but also, I want the original table with the new field
interest_spread
I want to be able to get either
I think this fixed the issue.
Copy code
@extract_columns('INTBAL', 'ITURN', 'YEAR', 'DAYS')
def load_tbl_interest(path: Union[str, List]) -> pd.DataFrame:
    '''Returns data given file path.'''
    if isinstance(path, str):
        return pd.read_csv(path)           
    return pd.concat([pd.read_csv(file) for file in path])
s
yep that is one way to expose it
s
but there are new issues, so please ignore what I had said
s
Copy code
df = dr.execute(['interest_spread'])
^ this should contain the list of columns you want to create a dataframe with.
s
How can the new column
interest_spread
be added to the
load_tbl_interest
so when I ask for
load_tbl_interest
the new column is returned with the original df?
Would I have to either create a new funciton with a join? Or just use dataframes instead and return the resulting dataframe?
s
One way: In your hamilton functions
Copy code
@extract_columns(*['INTERESTMONTH', 'INTBAL', 'TYPE',  ACCOUNT',  'IRATE', 'ITURN', 'YEAR', 'CCY', 'MARKET', DAYS'])
def load_tbl_interest(path: Union[str, List]) -> pd.DataFrame:
   ...
In the driver:
Copy code
df = dr.execute(['INTERESTMONTH', 'INTBAL', 'TYPE',  ACCOUNT',  'IRATE', 'ITURN', 'YEAR', 'CCY', 'MARKET', DAYS', 'interest_spread'])
👍 1
and hamilton will join it
or do it explicitly in a function as you suggested.
s
beautiful, thank you sir. so given that I will usually always want all the columns i should just decorate the load functions and then ask for all beginning columns and functions in the driver
👍 1