In pandas, DataFrame.iterrows() yields the index and the row. The index is something you control, and looking at your sample data you don't have an index that is densely-packed integers, but something else.
Try this code instead:
def dropNotIn(df):
def dropNotIn(df):
print(df.shape)
removedlist = []
droplist = []
num_rows = 0
for i, x in df.iterrows():
num_rows += 1
print(num_rows)
print(len(df))
This counts the rows explicitly, instead of trying to use the index. If you really want to count rows during your operations, I'd suggest using the builtin function enumerate for this:
for num, (index, row) in enumerate(df.iterrows()):
pass
However, I suspect you probably don't want to do that, because when you're doing things with a dataframe you want to vectorize them as much as possible.