This message was deleted.
# hamilton-help
s
This message was deleted.
s
@Peter Robinson IIUC you want:
COL_SET
below
Copy code
@extract_columns(*COL_SET)
def my_df(…) -> pd.DataFrame:
    # logic
    return some_df
to be different based on some
config
value? If so you should look at `@resolve` . It is a dynamic way to do this in one node — though a bit harder to read (it’s an advanced feature). Though I think two functions with
@config.when
isn’t a bad way to do it:
Copy code
def my_df(…) -> pd.DataFrame:
    # logic
    return some_df

@config.when(...)
@extract_columns(*COL_SET_1)
def extractor__1(my_df: pd.DataFrame) -> pd.DataFrame:
    return my_df

@config.when(...)
@extract_columns(*COL_SET_2)
def extractor__2(my_df: pd.DataFrame) -> pd.DataFrame:
    return my_df
e
+1 to having two separate ones — I think it’s a clean way of organizing it, and the readability gains trump the value of conciseness. That said, resolve is the power-user feature that’ll do this, and if you come up with an api that you think expresses it well and generalizes nicely, we can think about putting it in OS (or maybe having a user contributed/plugins piece)
👍 1
p
Great, thanks guys - will stick to having two separate ones for now and let you know if I think of a good api