I have a CSV file as such
ID OLD_A NEW_A OLD_B NEW_B OLD_C NEW_C
1 0 0 1/1/2017 1/1/2017 ABC BCD
2 0 0 1/1/2017 2/1/2017 ABC ABC
3 1 2 1/1/2017 1/1/2017 ABC BCD
I want to compare the old and new columns for A,B and C and in case there's a difference in the value of OLD and NEW (there's 10k+ rows) , I want return an output as such (from above example):
ID Field_Changed OLD_Value NEW_Value
1 C ABC BCD
2 B 1/1/2017 2/1/2017
3 A 1 2
3 C ABC BCD
So far I've used the .loc method of pandas.DataFrame which returns the indexed location of the rows that qualify the boolean indexing, but I need the values as well...
df.loc[(df['OLD_A'] != df['NEW_A'])].index)
I'm new to python scripting and cannot seem to figure the logic out. Can someone help please?