I use the Python shift function to compare if the value in the series is equal to the previous value. Primarily
import pandas as pd
a = pd.Series([2, 2, 4, 5])
a == a.shift()
Out[1]:
0 False
1 True
2 False
3 False
dtype: bool
This is as expected. (The first comparison is False because we are comparing from an NAoffset row). Now I have a series where I have no value, i.e. None, like this
b = pd.Series([None, None, 4, 5])
Here comparing the two NonegivesFalse
b == b.shift()
Out[3]:
0 False
1 False
2 False
3 False
dtype: bool
I would agree to accept some kind of philosophical justification, arguing that comparison is Nonepointless, etc., however
c = None
d = None
c == d
Out[4]: True
What's going on here?!
And what I really want to know is; how can I do a comparison of my b-Series, given that I want it to be Nonetreated as equal? That is, I want to b == b.shift()give the same result as a == a.shift().