I have a pandas DataFrame, then I apply the function to a column of columns and I get a new column of results. Then I want to check the results of a new column with the original column values.
ab 0 0 0 1 0 1 2 1 0 3 1 1
I want a single-line, without changing the original df, to return this (suppose I use the xor function):
ab xor 0 0 0 0 1 0 1 1 2 1 0 1 3 1 1 0
What am I doing now (I work in a shell, so the second line prints "df"):
df['result'] = df.apply(xor, axis=1) df
(foo gets the "row", and let it do something with all the columns, so I am not aiming for something specific to the column, in the end I want to see all the original columns and the result column next to them).
I do not like this parameter because it is two-stage AND changing the original frame. My goal is to test the function again and again, so I want to show the result next to the original values.
Is there a simple 1-step easy way to do this?
Thanks,
source share