I have created a function that joins all the dataframes via a left join and want it to be able to take a flexible number of arguments. The issue is that I need a list of all the dataframe names to use in the reduce function.So in the example below, I need all_dfs which is a list of all the arguments passed to the function. Any help would be much appreciated.
from functools import reduce
def myfunc(*args):
result = reduce(
lambda left, right: pd.merge(left, right, on=["p_key"], how="left"),
all_dfs
)
return result
CodePudding user response:
The name you're looking for is args
.