consider series x_1,x_2,x_3,x_4... I want to set x_i as NaN if x_i = x_{i+1}.... I don't care if x_2 equals, say, x_9. For a second or two, I had thought this was the meaning of duplicate values but I now see that it would care about x_9. I'm pretty sure this routine must already exist in pandas, but I can't find it.
def ff_repeated(xnp):
nfnp = xnp.size
ffnp = np.empty(nfnp,dtype=bool)
ffnp[0] = False
for i in range(1,nfnp):
ffnp[i] = xnp[i] == xnp[i-1]
return ffnp
Thoughts? How I use the above is then
ffnp = ff_repeated(dm.loc["Pressure"].values)
dm.loc["Pressure",ffnp] = np.NaN