Option 1: convert to lowercase or to uppercase and compare
The simplest is to convert the two columns to lower (or to upper) before checking for equality:
df=df[df['ConfigredValue'].str.lower()!=df['ReferenceValue'].str.lower()]
or
df=df[df['ConfigredValue'].str.upper()!=df['ReferenceValue'].str.upper()]
output:
Out:
Last Known Date ConfigredValue ReferenceValue
2 2 26-Jun-17 TRUE FALSE
Option 2: Compare the lengths
In this particuler case, you can simply compare the lengths of TRUE and True, they are the same wether the string is upper or lower case:
df[df['ConfigredValue'].str.len()!=df['ReferenceValue'].str.len()]
output:
Out:
Last Known Date ConfigredValue ReferenceValue
2 2 26-Jun-17 TRUE FALSE
Option 3: Vectorized title
str.title()
was also suggested in @0p3n5ourcE answer, here's a vectorized version of it:
df[df['ConfigredValue'].str.title()!=df['ReferenceValue'].str.title()]
Execution time
Benchmarking the speed shows that str.len()
is a bit faster
In [35]: timeit df[df['ConfigredValue'].str.lower()!=df['ReferenceValue'].str.lower()]
1000 loops, best of 3: 496 µs per loop
In [36]: timeit df[df['ConfigredValue'].str.upper()!=df['ReferenceValue'].str.upper()]
1000 loops, best of 3: 496 µs per loop
In [37]: timeit df[df['ConfigredValue'].str.title()!=df['ReferenceValue'].str.title()]
1000 loops, best of 3: 495 µs per loop
In [38]: timeit df[df['ConfigredValue'].str.len()!=df['ReferenceValue'].str.len()]
1000 loops, best of 3: 479 µs per loop