Why do I get: “Length of values does not match length of index” error?

My best guess relies in this part:

myTempData ['Actuals'] = [True] * len(MyActualData.index)
myTempData ['Actuals'] = [False] * len(MyExpectedData.index)

It first says that myTempData['Actuals'] is a column of size len(MyActualData.index) containing only True values. Next, it replaces everything by another column of size len(MyExpectedData.index) (which I expect to be different) containing False values.

You can first create a column of True values and, only then, replace False ones:

myTempData['Actuals'] = True
myTempData.iloc[MyExpectedIndex] = False

Leave a Comment