I have a dataset in Excel that I would like to replicate.
My python code looks like:
data_frames = [df_mainstore, df_store_A, df_store_B]
df_merged = reduce(lambda left,right: pd.merge(left,right,on=["Id_number"], how='outer'), data_frames)
print(df_merged)
Since I merge several dataframes (can vary in column number and name) it would be tedious too write out all the columns which is done in this example:
isY = lambda x:int(x=='Y')
countEmail= lambda row: isY(row['Store Contact A']) + isY(row['Store B Contact'])
df['Contact Email'] = df.apply(countEmail,axis=1)
I also struggle with the expression: isY = lambda x:int(x=='@')
How can I add the "Contact has Email" column in a similar way I would do in Excel?