I have a dataframe, df, that has a row of data that I wish to compare to a previous row of data. I would like to create a new row named 'Match'. I would like the values to show as 'TRUE' or 'FALSE', depending if they match or not.
Edited Added column names @3:14PM
col1 col2 col3 col4 col5
Row1 4 5 6 7 7
Row2 4 2 1 7 7
Desired output:
col1 col2 col3 col4 col5
Row1 4 5 6 7 7
Row2 4 2 1 7 7
Match TRUE FALSE FALSE TRUE TRUE
This is what I am doing:
df['match'] = df.Row1.eq(df.Row2.eq())
However, I think the code is specifying a 'column', when this is actually a row.
Any suggestion is appreciated.
df.eq(df.shift())