Repository: pandas-dev/pandas

Issue:
bug: interpolate() row-by-row doesn't work when setting inplace=True
``` python

# pandas version 0.16.2
import numpy as np
import pandas as pd

np.random.seed(12345)
# simulate some data
df = pd.DataFrame(np.random.randn(250, 10), columns=np.arange(1, 11), index=pd.date_range('2015-01-01', periods=250, freq='B'))
# set 20% data to NaN
sel = np.random.choice([True, False], size=(250, 10), p=[0.2, 0.8])
df.values[sel] = np.nan

# row-wise interpolation doesn't work when setting inplace=True
df1 = df.copy()
df1.interpolate(method='linear', axis=1, inplace=True)

# inplace doesn't work
import pandas.util.testing as pdt
pdt.assert_frame_equal(df, df1)

# dropping inplace=True, it works
df2 = df.copy()
df2 = df2.interpolate(method='linear', axis=1)
pdt.assert_frame_equal(df, df2)

```



Discussion:
marking as a bug


Resolving patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -2925,47 +2925,50 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
 
         if axis == 0:
             ax = self._info_axis_name
+            _maybe_transposed_self = self
         elif axis == 1:
-            self = self.T
+            _maybe_transposed_self = self.T
             ax = 1
-        ax = self._get_axis_number(ax)
+        else:
+            _maybe_transposed_self = self
+        ax = _maybe_transposed_self._get_axis_number(ax)
 
-        if self.ndim == 2:
+        if _maybe_transposed_self.ndim == 2:
             alt_ax = 1 - ax
         else:
             alt_ax = ax
 
-        if isinstance(self.index, MultiIndex) and method != 'linear':
+        if isinstance(_maybe_transposed_self.index, MultiIndex) and method != 'linear':
             raise ValueError("Only `method=linear` interpolation is supported "
                              "on MultiIndexes.")
 
-        if self._data.get_dtype_counts().get('object') == len(self.T):
+        if _maybe_transposed_self._data.get_dtype_counts().get('object') == len(_maybe_transposed_self.T):
             raise TypeError("Cannot interpolate with all NaNs.")
 
         # create/use the index
         if method == 'linear':
-            index = np.arange(len(self._get_axis(alt_ax)))  # prior default
+            index = np.arange(len(_maybe_transposed_self._get_axis(alt_ax)))  # prior default
         else:
-            index = self._get_axis(alt_ax)
+            index = _maybe_transposed_self._get_axis(alt_ax)
 
         if pd.isnull(index).any():
             raise NotImplementedError("Interpolation with NaNs in the index "
                                       "has not been implemented. Try filling "
                                       "those NaNs before interpolating.")
-        new_data = self._data.interpolate(method=method,
-                                          axis=ax,
-                                          index=index,
-                                          values=self,
-                                          limit=limit,
-                                          inplace=inplace,
-                                          downcast=downcast,
-                                          **kwargs)
+        new_data = _maybe_transposed_self._data.interpolate(
+            method=method,
+            axis=ax,
+            index=index,
+            values=_maybe_transposed_self,
+            limit=limit,
+            inplace=inplace,
+            downcast=downcast,
+            **kwargs
+        )
         if inplace:
             if axis == 1:
-                self._update_inplace(new_data)
-                self = self.T
-            else:
-                self._update_inplace(new_data)
+                new_data = self._constructor(new_data).T._data
+            self._update_inplace(new_data)
         else:
             res = self._constructor(new_data).__finalize__(self)
             if axis == 1:


Test patch:
diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py
--- a/pandas/tests/test_generic.py
+++ b/pandas/tests/test_generic.py
@@ -1117,6 +1117,14 @@ def test_interp_inplace(self):
         result['a'].interpolate(inplace=True, downcast='infer')
         assert_frame_equal(result, expected.astype('int64'))
 
+    def test_interp_inplace_row(self):
+        # GH 10395
+        result = DataFrame({'a': [1.,2.,3.,4.], 'b': [np.nan, 2., 3., 4.],
+                            'c': [3, 2, 2, 2]})
+        expected = result.interpolate(method='linear', axis=1, inplace=False)
+        result.interpolate(method='linear', axis=1, inplace=True)
+        assert_frame_equal(result, expected)
+
     def test_interp_ignore_all_good(self):
         # GH
         df = DataFrame({'A': [1, 2, np.nan, 4],