Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with irow and list of indices #654

Closed
gerigk opened this issue Jan 20, 2012 · 2 comments
Closed

Bug with irow and list of indices #654

gerigk opened this issue Jan 20, 2012 · 2 comments
Milestone

Comments

@gerigk
Copy link

gerigk commented Jan 20, 2012

from pandas import *
import numpy as np
x=DataFrame(np.arange(9).reshape(3,3))
x[0].iget([0,1])
0 0
1 3
x.icol([0,1])
0 1
0 0 1
1 3 4
2 6 7
x.irow([0,1])

Traceback (most recent call last):
File "<pyshell#5>", line 1, in
x.irow([0,1])
File "C:\Python27\lib\site-packages\pandas-0.7.0rc1-py2.7-win32.egg\pandas\core\frame.py", line 1238, in irow
return self.xs(label)
File "C:\Python27\lib\site-packages\pandas-0.7.0rc1-py2.7-win32.egg\pandas\core\frame.py", line 1498, in xs
loc = self.index.get_loc(key)
File "C:\Python27\lib\site-packages\pandas-0.7.0rc1-py2.7-win32.egg\pandas\core\index.py", line 478, in get_loc
return self._engine.get_loc(key)
File "engines.pyx", line 100, in pandas._engines.DictIndexEngine.get_loc (pandas\src\engines.c:2497)
File "engines.pyx", line 102, in pandas._engines.DictIndexEngine.get_loc (pandas\src\engines.c:2409)
TypeError

@gerigk
Copy link
Author

gerigk commented Jan 20, 2012

I think the function iget currently does something very different with lists than I thought ( i.e., printing the first len(list) elements for integers or, if passing a boolean list of len k<=number_elements it prints the subset of the first k elements according to True/False )

one more here:

x
a 0 1
a 0 1 2
b 3 4 5
c 6 7 8
for bla,row in x.iterrows(): print row.iget([1,2])

a 0
0 1
Name: a
a 3
0 4
Name: b
a 6
0 7
Name: c

for bla,row in x.iterrows(): print row.iget(1)

1
4
7

for bla,row in x.iterrows(): print row.iget(2)

2
5
8

for bla,row in x.iterrows(): print row.iget([True,False,True])

a 0
1 2
Name: a
a 3
1 5
Name: b
a 6
1 8
Name: c

@gerigk gerigk closed this as completed Jan 20, 2012
@gerigk gerigk reopened this Jan 20, 2012
@wesm
Copy link
Member

wesm commented Jan 23, 2012

OK I have enabled irow/icol/iget to be able to take a list of array of integers. I get this now:


In [7]: for bla,row in x.iterrows(): print row.iget([1,2])
0    1
1    2
Name: a
0    4
1    5
Name: b
0    7
1    8
Name: c

the last example looks like the correct behavior to me

@wesm wesm closed this as completed Jan 23, 2012
dan-nadler pushed a commit to dan-nadler/pandas that referenced this issue Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants