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

Projects
None yet
3 participants
@sinhrks
Member

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 this to the 0.19.1 milestone Oct 14, 2016

@codecov-io

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io 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

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):

This comment has been minimized.

@jorisvandenbossche

jorisvandenbossche Oct 14, 2016

Member

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

@jorisvandenbossche

jorisvandenbossche Oct 14, 2016

Member

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

This comment has been minimized.

@sinhrks

sinhrks Oct 16, 2016

Member

sure, added the comment.

@sinhrks

sinhrks Oct 16, 2016

Member

sure, added the comment.

@jorisvandenbossche

This comment has been minimized.

Show comment
Hide comment
@jorisvandenbossche

jorisvandenbossche Oct 14, 2016

Member

Small comment, looks good for the rest

Member

jorisvandenbossche commented Oct 14, 2016

Small comment, looks good for the rest

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jorisvandenbossche

This comment has been minimized.

Show comment
Hide comment
Member

jorisvandenbossche commented Oct 22, 2016

@sinhrks Thanks!

@sinhrks sinhrks deleted the sinhrks:partial_string_bug branch Oct 23, 2016

jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this pull request Nov 2, 2016

amolkahat added a commit to amolkahat/pandas that referenced this pull request Nov 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment