I have dataframe as given below:
df =
0
1 0.993995
2 1.111068
3 1.760940
.
.
.
49 40.253574
50 40.664486
51 41.083962
I am iterating through each row and print each element. My code is given below:
for idx,row in df.iterrows():
print(df[0].iloc[idx])
Present output:
1.111068
1.76094
2.691832
.
.
40.664486
41.083962
Traceback (most recent call last):
File "<ipython-input-46-80539a9081e5>", line 2, in <module>
print(darkdf[0].iloc[idx])
File "C:\Users\MM\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1500, in __getitem__
return self._getitem_axis(maybe_callable, axis=axis)
File "C:\Users\MM\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2230, in _getitem_axis
self._validate_integer(key, axis)
File "C:\Users\MM\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 2139, in _validate_integer
raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds
Why this simple function is giving error. Someone could help me to understand what the error is saying?