I am looking to write a quick script that will run through a csv file with two columns and provide me the rows in which the values in column B switch from one value to anoth
You can create a new column for the difference
> df['C'] = df['B'].diff() > print df # A B C 0 1 2 3 NaN 1 2 3 3 0 2 3 4 4 1 3 4 5 4 0 4 5 5 4 0 > df_filtered = df[df['C'] != 0] > print df_filtered # A B C 2 3 4 4 1
This will your required rows