Im performing some operation within the dataframe and then splitting it into two dataframes. my problem is when i use the return function it combines both dataframes and return them as a tuple instead of two separate dataframes.
def block_dsgn(design,clmn='a',val=-1):
if design[clmn].eq(val).any():
blck1 = pd.DataFrame(design[design[clmn]==val])
blck2 = pd.DataFrame(design[design[clmn]!= val])
return blck1, blck2
if ~ design[clmn].eq(val).any():
return 'check block factor value...val parameter'
CodePudding user response:
Is it what you want?
def block_dsgn(design,clmn='a',val=-1):
if design[clmn].eq(val).any():
blck1 = pd.DataFrame(design[design[clmn]==val])
blck2 = pd.DataFrame(design[design[clmn]!= val])
return blck1, blck2
a, b = block_dsgn(...)
a and b are two separate dataframes