I have two dataframes:
df1 = pd.DataFrame(rng.rand(1000, 3), columns=['A', 'B', 'C'])
df2 = pd.DataFrame(rng.rand(1000, 3), columns=['A', 'B', 'C'])
I also have a column consisting of "Y" and "N":
df0['Split'] = ['Y', 'N', 'Y'...]
I want to create a 3rd dataframe that returns df1 if df0['Split'] = 'Y' and returns df2 if df0['Split'] = 'N'. I'd like to keep the shape of the original two dataframes if possible.
I thought I could do something such as the following:
if df0['Split'] == Y:
return df1
if df0['Split'] == N:
return df2
else:
return 0
In reality, I have a lot more columns than A through C. Appreciate your help.