Skip to content

BUG: Bug in Series.get with a boolean accessor (GH7407) #7638

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

Merged
merged 1 commit into from
Jul 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Bug Fixes
- Bug in timeops with non-aligned Series (:issue:`7500`)
- Bug in timedelta inference when assigning an incomplete Series (:issue:`7592`)
- Bug in groupby ``.nth`` with a Series and integer-like column name (:issue:`7559`)

- Bug in ``Series.get`` with a boolean accessor (:issue:`7407`)
- Bug in ``value_counts`` where ``NaT`` did not qualify as missing (``NaN``) (:issue:`7423`)
- Bug in ``to_timedelta`` that accepted invalid units and misinterpreted 'm/h' (:issue:`7611`, :issue: `6423`)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def get_value(self, series, key):
try:
return self._engine.get_value(s, k)
except KeyError as e1:
if len(self) > 0 and self.inferred_type == 'integer':
if len(self) > 0 and self.inferred_type in ['integer','boolean']:
raise

try:
Expand Down
14 changes: 14 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ def test_get(self):
expected = 43
self.assertEqual(result,expected)

# GH 7407
# with a boolean accessor
df = pd.DataFrame({'i':[0]*3, 'b':[False]*3})
vc = df.i.value_counts()
result = vc.get(99,default='Missing')
self.assertEquals(result,'Missing')

vc = df.b.value_counts()
result = vc.get(False,default='Missing')
self.assertEquals(result,3)

result = vc.get(True,default='Missing')
self.assertEquals(result,'Missing')

def test_delitem(self):

# GH 5542
Expand Down