I'm working with data science and I have a pretty big script consisting of a lot of helper functions to run analysis on pandas dataframes and then one main function that utilizes my functions to get some results.
The issue is that most or the function inputs are just names of the columns in the dataframe (because they are taken as input from users) and this leads to a lot of functions have partially the same input.
What I wonder is if it possible to have a dict containing all my parameters and simply pass the dict to every function without modifying the dict? That is, each function would have to ignore the keywords in the dict that are not an input to that particular function.
To give an example say I have this function.
def func1(a, b, c):
return a + b * c
And I have this dict containing the inputs to all my functions.
input_dict = {'a': 1,
'b': 2,
'c': 3,
'd': 4}
If I call this function with this dict as input like this:
value = func1(**input_dict)
I will get an error because of the unexpected argument d.
Any workaround here that doesnt involve altering the dict? My code works but I would love to get away from having so many repeated input arguments everywhere.
Thanks in advance :)