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

'labels' as a DataFrame column name in version 0.14.1 #8082

Closed
FragLegs opened this issue Aug 20, 2014 · 2 comments
Closed

'labels' as a DataFrame column name in version 0.14.1 #8082

FragLegs opened this issue Aug 20, 2014 · 2 comments
Labels
Milestone

Comments

@FragLegs
Copy link
Contributor

I'm not sure if this qualifies as a bug, but it is a change that occurred between 0.13.1 and 0.14.1. In 0.14.1, if I have a DataFrame with a column named 'labels', I get the following error when trying to access it as an attribute of the DataFrame:

>>> df = pandas.DataFrame(columns=['labels'])
>>> df['labels']
Series([], name: labels, dtype: object)
>>> df.labels
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/<virtual_env>/local/lib/python2.7/site-packages/pandas/core/generic.py", line 1836, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'labels'

In 0.13.1, this code did not throw an error. This is with Python 2.7.6.

@jreback
Copy link
Contributor

jreback commented Aug 21, 2014

this section should be updated a bit: http://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access

Their are a couple of 'reserved' names that are checked before the actual column names (this is done for efficiency). This could technically be avoided, but would require a bit of code to do that.

e.g.

index,major_axis,minor_axis,items,labels iow the names of the axes.

So these work with df['index'] but not attribute access.

care to do a pull-request to update?

@jreback
Copy link
Contributor

jreback commented Sep 13, 2014

closed by #8100

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.

2 participants