I have a function to perform multiple tasks. And I need to pass optional strings/variables and optional data frame with other values. For example, this is my function.
def main(df,option=None,type=None, *args)
if type == "cars":
#multiple functions..
df = function1(df)
results = function2(df)
if option =="ex":
results = function4(results)
elif option =="CDS":
result = function5(results)
elif type == "buses":
df2 = pd_read_csv("data2",sep="\t",header=0) # This is the optional data frame I wannna pass
def func3(df2,results,df):
result["col3"] =pd.merge(df2,df, on="col1")
return result
if option =="ex":
results = function4(results)
elif option =="CDS":
result = function5(results)
return(result)
I have two optional variables passed to my function main already option and type. Now I need to pass one more optional variable that is df2. But I do not know how can do it. The above example is a template from my main function. Here, I wanna add df2 to the main() and use it in first elif loop for buses.
Any suggestions or help is much appreciated
def main(df,option=None,type=None,df2=None, *args)?elif loop.