Ok, thanks for the clarification, that makes sense, so inclusionMatrix is not a matrix of all the stocks that are listed on a specific date? 1 being it is listed, 0 being it is not? If I run the code below, it gives me 319 changes between 2006 and 2017, which is not how many changes I would expect in the SP500.
df = DataFeatures(tickers=list(getTickersSP500()[‘ticker’].unique()),fields=[‘ohlc’,‘bb_live’])
inclusionMatrix = getTickersSP500(ticker=df.tickers, startDate=df.startDate, endDate=df.endDate, asMatrix=True)
number_of_changes = 0
indices_with_changes = []
for i in range(1,len(inclusionMatrix)):
if (np.array(list(map(bool,inclusionMatrix.iloc[i])))==np.array(list(map(bool,inclusionMatrix.iloc[i-1])))).all():
continue
else:
number_of_changes+=1
indices_with_changes.append(i)
print(number_of_changes)