Pandas "diff()" with string : <p>How can I flag a row in a dataframe every time a column change its string value?</p>

<p>Ex:</p>

<p>Input</p>

<pre><code>ColumnA   ColumnB
1            Blue
2            Blue
3            Red
4            Red
5            Yellow


#  diff won't work here with strings....  only works in numerical values
dataframe['changed'] = dataframe['ColumnB'].diff()        


ColumnA   ColumnB      changed
1            Blue         0
2            Blue         0
3            Red          1
4            Red          0
5            Yellow       1
</code></pre>
