Skip to content

AttributeError Block.items #17159

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

Closed
jbrockmendel opened this issue Aug 3, 2017 · 4 comments · Fixed by #17169
Closed

AttributeError Block.items #17159

jbrockmendel opened this issue Aug 3, 2017 · 4 comments · Fixed by #17169
Labels
Milestone

Comments

@jbrockmendel
Copy link
Member

https://github.com/pandas-dev/pandas/blob/master/pandas/core/internals.py#L326

core.internals.Block references self.items. AFAICT items is an attribute of BlockManager, does not exist in Block.

ser = pd.Series(range(5))
mgr = ser._data
block = mgr.blocks[0]
>>> block.get(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/internals.py", line 329, in get
    loc = self.items.get_loc(item)
AttributeError: 'IntBlock' object has no attribute 'items'
@jreback
Copy link
Contributor

jreback commented Aug 3, 2017

I think this is dead code. We always use positional indexing on a block (e.g. .iget). not sure why the linter doesn't find this. you can do a PR to remove.

@jreback jreback added this to the 0.21.0 milestone Aug 3, 2017
@jreback jreback added the Clean label Aug 3, 2017
@jorisvandenbossche
Copy link
Member

Code coverage also indicates this is never used (at least in our tests)

@jbrockmendel
Copy link
Member Author

About to make a PR for this. In doing this I noticed that there are reindex_axis methods defined in Block and SparseBlock that are never hit. Any chance these fall into the same category?

@jorisvandenbossche
Copy link
Member

There are some usages of reindex_axis in the rest of the internals.py file, but it would need some more introspection to see whether this are calls on a block, or on something else that has such a method (eg there are some hasatrr(values, 'reindex_axis') calls, not sure if that would show in coverage if values is a block).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants