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: String indexing against object dtype may raise AttributeError #14424

Merged
merged 1 commit into from Oct 22, 2016

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Oct 14, 2016

  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

String indexing may raise AttributeError, rather than KeyError.

df = pd.DataFrame([1], pd.Index([pd.Timestamp('2011-01-01')], dtype=object))
df.index.is_all_dates
# True
df['2011']
# AttributeError: 'Index' object has no attribute '_get_string_slice'

@sinhrks sinhrks added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Oct 14, 2016
@sinhrks sinhrks added this to the 0.19.1 milestone Oct 14, 2016
@codecov-io
Copy link

codecov-io commented Oct 14, 2016

Current coverage is 85.25% (diff: 100%)

Merging #14424 into master will increase coverage by <.01%

@@             master     #14424   diff @@
==========================================
  Files           140        140          
  Lines         50631      50632     +1   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43167      43168     +1   
  Misses         7464       7464          
  Partials          0          0          

Powered by Codecov. Last update 7cad3f1...ae22dce

@@ -2936,6 +2936,9 @@ def _wrap_joined_index(self, joined, other):
name = self.name if self.name == other.name else None
return Index(joined, name=name)

def _get_string_slice(self, key, use_lhs=True, use_rhs=True):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a docstring or comment explaining where this is overwritten / used ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, added the comment.

@jorisvandenbossche
Copy link
Member

Small comment, looks good for the rest

@jorisvandenbossche jorisvandenbossche merged commit 233d51d into pandas-dev:master Oct 22, 2016
@jorisvandenbossche
Copy link
Member

@sinhrks Thanks!

@sinhrks sinhrks deleted the partial_string_bug branch October 23, 2016 04:50
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this pull request Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants