Skip to content

Commit 7c1d8a0

Browse files
committed
Merge pull request #6385 from jreback/get_bug
BUG: Bug in Series.get, was using a buggy access method (GH6383)
2 parents 173c686 + 6ec6df7 commit 7c1d8a0

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

doc/source/release.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Bug Fixes
124124
keys not in the values to be replaced (:issue:`6342`)
125125
- Bug in take with duplicate columns not consolidated (:issue:`6240`)
126126
- Bug in interpolate changing dtypes (:issue:`6290`)
127+
- Bug in Series.get, was using a buggy access method (:issue:`6383`)
127128

128129
pandas 0.13.1
129130
-------------

pandas/core/series.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -702,27 +702,6 @@ def reshape(self, *args, **kwargs):
702702

703703
return self.values.reshape(shape, **kwargs)
704704

705-
def get(self, label, default=None):
706-
"""
707-
Returns value occupying requested label, default to specified
708-
missing value if not present. Analogous to dict.get
709-
710-
Parameters
711-
----------
712-
label : object
713-
Label value looking for
714-
default : object, optional
715-
Value to return if label not in index
716-
717-
Returns
718-
-------
719-
y : scalar
720-
"""
721-
try:
722-
return self.get_value(label)
723-
except KeyError:
724-
return default
725-
726705
iget_value = _ixs
727706
iget = _ixs
728707
irow = _ixs

pandas/tests/test_series.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,28 @@ def test_combine_first_dt64(self):
113113
xp = Series([datetime(2010, 1, 1), '2011'])
114114
assert_series_equal(rs, xp)
115115

116+
def test_get(self):
117+
118+
# GH 6383
119+
s = Series(np.array([43, 48, 60, 48, 50, 51, 50, 45, 57, 48, 56,
120+
45, 51, 39, 55, 43, 54, 52, 51, 54]))
121+
122+
result = s.get(25, 0)
123+
expected = 0
124+
self.assertEquals(result,expected)
125+
126+
s = Series(np.array([43, 48, 60, 48, 50, 51, 50, 45, 57, 48, 56,
127+
45, 51, 39, 55, 43, 54, 52, 51, 54]),
128+
index=pd.Float64Index([25.0, 36.0, 49.0, 64.0, 81.0, 100.0,
129+
121.0, 144.0, 169.0, 196.0, 1225.0,
130+
1296.0, 1369.0, 1444.0, 1521.0, 1600.0,
131+
1681.0, 1764.0, 1849.0, 1936.0],
132+
dtype='object'))
133+
134+
result = s.get(25, 0)
135+
expected = 43
136+
self.assertEquals(result,expected)
137+
116138
def test_delitem(self):
117139

118140
# GH 5542

0 commit comments

Comments
 (0)