Consider this small script:
import pandas as pd
aa = pd.DataFrame({'a': [1,2,3]})
bb = aa.a
bb.index = bb.index + 1
aa['b'] = bb
print(aa)
print(aa.a - aa.b)
the output is:
a b
0 1 NaN
1 2 1.0
2 3 2.0
0 NaN
1 0.0
2 0.0
3 NaN
while I was expecting aa.a - aa.b to be
0 NaN
1 1.0
2 1.0
How is this possible? Is it a Pandas bug?