0
s = pandas.Series([True,False,True,True,False])
len(s)==5

while len(s[:-1]) == len(s[1:]) = 4,

the element-wise AND combination len(s[1:] & s[:-1]) = 5,

even len(s[1:].copy() & s[:-1].copy()) = 5

environment is python3.6 on Jupyter, pandas 0.21.0

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Shark
  • 11
  • 2

1 Answers1

0

Its because element-wise logical & operation is strictly based on indexing. And the combination of two mis-indexed series gives None, which is treated as False. The combination is full-join, so final length is len(s) == len(s[1:] & s[:-1]) = 5.

Shark
  • 11
  • 2