Skip to content

Commit a1c3027

Browse files
committed
BUG: Bug in Series.get with a boolean accessor (GH7407)
1 parent 715945c commit a1c3027

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

doc/source/v0.14.1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Bug Fixes
173173
- Bug in timeops with non-aligned Series (:issue:`7500`)
174174
- Bug in timedelta inference when assigning an incomplete Series (:issue:`7592`)
175175
- Bug in groupby ``.nth`` with a Series and integer-like column name (:issue:`7559`)
176-
176+
- Bug in ``Series.get`` with a boolean accessor (:issue:`7407`)
177177
- Bug in ``value_counts`` where ``NaT`` did not qualify as missing (``NaN``) (:issue:`7423`)
178178
- Bug in ``to_timedelta`` that accepted invalid units and misinterpreted 'm/h' (:issue:`7611`, :issue: `6423`)
179179

pandas/core/index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ def get_value(self, series, key):
11911191
try:
11921192
return self._engine.get_value(s, k)
11931193
except KeyError as e1:
1194-
if len(self) > 0 and self.inferred_type == 'integer':
1194+
if len(self) > 0 and self.inferred_type in ['integer','boolean']:
11951195
raise
11961196

11971197
try:

pandas/tests/test_series.py

+14
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ def test_get(self):
123123
expected = 43
124124
self.assertEqual(result,expected)
125125

126+
# GH 7407
127+
# with a boolean accessor
128+
df = pd.DataFrame({'i':[0]*3, 'b':[False]*3})
129+
vc = df.i.value_counts()
130+
result = vc.get(99,default='Missing')
131+
self.assertEquals(result,'Missing')
132+
133+
vc = df.b.value_counts()
134+
result = vc.get(False,default='Missing')
135+
self.assertEquals(result,3)
136+
137+
result = vc.get(True,default='Missing')
138+
self.assertEquals(result,'Missing')
139+
126140
def test_delitem(self):
127141

128142
# GH 5542

0 commit comments

Comments
 (0)