Repository: pandas-dev/pandas

Issue:
BUG: convert_objects on > 2ndim raises
```
In [40]: x = Panel(dict(A = dict(a = ['1','1.0'])))

In [41]: x
Out[41]: 
<class 'pandas.core.panel.Panel'>
Dimensions: 1 (items) x 2 (major_axis) x 1 (minor_axis)
Items axis: A to A
Major_axis axis: 0 to 1
Minor_axis axis: a to a

In [42]: x.values
Out[42]: 
array([[['1'],
        ['1.0']]], dtype=object)

In [43]: x.convert_objects(convert_numeric='force')
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)
```



Discussion:

Resolving patch:
diff --git a/pandas/core/internals.py b/pandas/core/internals.py
--- a/pandas/core/internals.py
+++ b/pandas/core/internals.py
@@ -1164,8 +1164,8 @@ def convert(self, convert_dates=True, convert_numeric=True, copy=True, by_item=T
                 values = self.iget(i)
 
                 values = com._possibly_convert_objects(
-                    values, convert_dates=convert_dates, convert_numeric=convert_numeric)
-                values = _block_shape(values)
+                    values.ravel(), convert_dates=convert_dates, convert_numeric=convert_numeric).reshape(values.shape)
+                values = _block_shape(values, ndim=self.ndim)
                 items = self.items.take([i])
                 placement = None if is_unique else [i]
                 newb = make_block(
@@ -1175,7 +1175,7 @@ def convert(self, convert_dates=True, convert_numeric=True, copy=True, by_item=T
         else:
 
             values = com._possibly_convert_objects(
-                self.values, convert_dates=convert_dates, convert_numeric=convert_numeric)
+                self.values.ravel(), convert_dates=convert_dates, convert_numeric=convert_numeric).reshape(self.values.shape)
             blocks.append(
                 make_block(values, self.items, self.ref_items, ndim=self.ndim))
 
@@ -3610,7 +3610,7 @@ def _merge_blocks(blocks, items, dtype=None, _can_consolidate=True):
 
 def _block_shape(values, ndim=1, shape=None):
     """ guarantee the shape of the values to be at least 1 d """
-    if values.ndim == ndim:
+    if values.ndim <= ndim:
         if shape is None:
             shape = values.shape
         values = values.reshape(tuple((1,) + shape))


Test patch:
diff --git a/pandas/tests/test_panel.py b/pandas/tests/test_panel.py
--- a/pandas/tests/test_panel.py
+++ b/pandas/tests/test_panel.py
@@ -1010,6 +1010,14 @@ def test_conform(self):
         assert(conformed.index.equals(self.panel.major_axis))
         assert(conformed.columns.equals(self.panel.minor_axis))
 
+    def test_convert_objects(self):
+
+        # GH 4937
+        p = Panel(dict(A = dict(a = ['1','1.0'])))
+        expected = Panel(dict(A = dict(a = [1,1.0])))
+        result = p.convert_objects(convert_numeric='force')
+        assert_panel_equal(result, expected)
+
     def test_reindex(self):
         ref = self.panel['ItemB']
 
@@ -1287,9 +1295,6 @@ def test_to_panel_duplicates(self):
     def test_filter(self):
         pass
 
-    def test_apply(self):
-        pass
-
     def test_compound(self):
         compounded = self.panel.compound()
 
@@ -1350,7 +1355,7 @@ def test_tshift(self):
         assert_panel_equal(shifted, shifted2)
 
         inferred_ts = Panel(panel.values,
-                                items=panel.items, 
+                                items=panel.items,
                                 major_axis=Index(np.asarray(panel.major_axis)),
                                 minor_axis=panel.minor_axis)
         shifted = inferred_ts.tshift(1)