There’s lots related to this on Stackoverflow etc, but I’m struggling with a neat and efficient code to put it together. I’m new to pandas/python - I’m sure people here can improve this. As in the subject I just want to compare columns that should be identical but shifted in indexes. Neat but error throwing code:
ishift=24*60 len(df[df["col1"][:-ishift]!=df["col2"][ishift:]])
returns #ValueError: Can only compare identically-labeled Series objects
because
print(df[“col1”][:-ishift].index , df[“col2”][ishift:].index
RangeIndex(start=0, stop=28560, step=1) RangeIndex(start=1440, stop=30000, step=1)
I’ve messed around with copies, and resetting indexes etc , but this (working example) is really ugly to me
a=df["col2"][180:] a=a.reset_index(drop=True) b=df["col1"][:-180] print(len(b), len(b!=a))