Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88809

python:for loop variable didn't work in iloc in data frame

$
0
0

iam trying by loop to go throw excel sheet to get value

and iam creating list to go throw excel sheet by index (0,1)

but iloc didnot work in for loop

m=[(df.iloc[(r,c)]) for r in range(25) for c in range(4)]
print(m)

i got below error

Traceback (most recent call last):
  File "D:/Lesson python/python excel.py", line 32, in <module>
    m=[(df.iloc[(r,c)]) for r in range(25) for c in range(4)]
  File "D:/Lesson python/python excel.py", line 32, in <listcomp>
    m=[(df.iloc[(r,c)]) for r in range(25) for c in range(4)]
  File "C:\Users\s84029240\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexing.py", line 1418, in __getitem__
    return self._getitem_tuple(key)
  File "C:\Users\s84029240\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexing.py", line 2092, in _getitem_tuple
    self._has_valid_tuple(tup)
  File "C:\Users\s84029240\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexing.py", line 235, in _has_valid_tuple
    self._validate_key(k, i)
  File "C:\Users\s84029240\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexing.py", line 2014, in _validate_key
    self._validate_integer(key, axis)
  File "C:\Users\s84029240\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexing.py", line 2088, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds

Viewing all articles
Browse latest Browse all 88809

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>