I have a list of processes over dataframes, consisting of functions and methods; and I want to call them in a loop.
For functions I can simply call
function_name(df, **options )
type of function_name here is a function.
For method all works with:
command = 'df.%s( **options )' % method_name
eval( command )
type of process_name here is str.
I've tried to store it like:
method = pd.DataFrame.set_index
function pandas.core.frame.DataFrame.set_index(self, keys, drop=True, append=False, inplace=False, verify_integrity=False)
But calling it afterwards:
df.method( **options )
leads to error:
AttributeError: 'DataFrame' object has no attribute 'method'
I have heard that using eval is bad. What code can replace line with eval above?