everyone! I am new to data science and I was playing around with pandas module in python. I wrote a code using for loop which is given below:

I then wrote the following code:

`import numpy as np for row in read.['OWN_OCCUPIED']: read.loc[row,'OWN_OCCUPIED']=np.nan print(read)`

which shows the following the result: I am really confused because why did the computer iterate through the row indexes and also the row elements i. e ‘Y’, ‘N’ and ’12’ ? Shouldn’t it have iterated only eight times same as the row numbers?

But when I write this following code:

`'import numpy as np count = 0 for row in read['OWN_OCCUPIED']: read.loc[count,'OWN_OCCUPIED']=np.nan count += 1' `

I get the desired result which is: Why is this happening and can someone tell me the logic behind it? Thank you.