Repository: pandas-dev/pandas

Issue:
Bug in series.get?
This showed up in the test suite for a PR for statsmodels. I have very little idea where this Series came from or why it's using get like this, but here it is anyway.

```
df = pd.Series(np.array([43, 48, 60, 48, 50, 51, 50, 45, 57, 48, 56, 
                        45, 51, 39, 55, 43, 54, 52, 51, 54]), 
                  index=pd.Float64Index([25.0, 36.0, 49.0, 64.0, 81.0, 100.0, 
                                  121.0, 144.0, 169.0, 196.0, 1225.0, 
                                  1296.0, 1369.0, 1444.0, 1521.0, 1600.0,
                                  1681.0, 1764.0, 1849.0, 1936.0], 
                                  dtype='object'))
df.get(25, 0)
```

Traceback:

```
----> 1 df.get(25, 0)

/home/skipper/src/pandas-skipper/pandas/core/series.pyc in get(self, label, default)
    756         """
    757         try:
--> 758             return self.get_value(label)
    759         except KeyError:
    760             return default

/home/skipper/src/pandas-skipper/pandas/core/series.pyc in get_value(self, label)
    776         value : scalar value
    777         """
--> 778         return self.index.get_value(self.values, label)
    779 
    780     def set_value(self, label, value):

/home/skipper/src/pandas-skipper/pandas/core/index.pyc in get_value(self, series, key)
1821         k = _values_from_object(key)
1822         loc = self.get_loc(k)
-> 1823         new_values = series.values[loc]
1824         if np.isscalar(new_values):
1825             return new_values

AttributeError: 'numpy.ndarray' object has no attribute 'values'
```

Version

```
[~/]
[11]: pd.version.version
[11]: '0.13.1-105-g8119991'
```



Discussion:

Resolving patch:
diff --git a/pandas/core/series.py b/pandas/core/series.py
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -702,27 +702,6 @@ def reshape(self, *args, **kwargs):
 
         return self.values.reshape(shape, **kwargs)
 
-    def get(self, label, default=None):
-        """
-        Returns value occupying requested label, default to specified
-        missing value if not present. Analogous to dict.get
-
-        Parameters
-        ----------
-        label : object
-            Label value looking for
-        default : object, optional
-            Value to return if label not in index
-
-        Returns
-        -------
-        y : scalar
-        """
-        try:
-            return self.get_value(label)
-        except KeyError:
-            return default
-
     iget_value = _ixs
     iget = _ixs
     irow = _ixs


Test patch:
diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py
--- a/pandas/tests/test_series.py
+++ b/pandas/tests/test_series.py
@@ -113,6 +113,28 @@ def test_combine_first_dt64(self):
         xp = Series([datetime(2010, 1, 1), '2011'])
         assert_series_equal(rs, xp)
 
+    def test_get(self):
+
+        # GH 6383
+        s = Series(np.array([43, 48, 60, 48, 50, 51, 50, 45, 57, 48, 56,
+                             45, 51, 39, 55, 43, 54, 52, 51, 54]))
+
+        result = s.get(25, 0)
+        expected = 0
+        self.assertEquals(result,expected)
+
+        s = Series(np.array([43, 48, 60, 48, 50, 51, 50, 45, 57, 48, 56,
+                             45, 51, 39, 55, 43, 54, 52, 51, 54]),
+                   index=pd.Float64Index([25.0, 36.0, 49.0, 64.0, 81.0, 100.0,
+                                          121.0, 144.0, 169.0, 196.0, 1225.0,
+                                          1296.0, 1369.0, 1444.0, 1521.0, 1600.0,
+                                          1681.0, 1764.0, 1849.0, 1936.0],
+                                         dtype='object'))
+
+        result = s.get(25, 0)
+        expected = 43
+        self.assertEquals(result,expected)
+
     def test_delitem(self):
 
         # GH 5542