Not the answer, but my recreation of the problem:
In [2]: df = pd.DataFrame([[1, 2, 'a'], [3, 4, 'b']], dtype=np.float32) In [3]: df.dtypes Out[3]: 0 float32 1 float32 2 object dtype: object In [4]: A=df.ix[:,:1].values In [5]: A Out[5]: array([[ 1., 2.], [ 3., 4.]], dtype=float32) In [6]: df.ix[:,:1] = A In [7]: df.dtypes Out[7]: 0 float64 1 float64 2 object dtype: object In [8]: pd.__version__ Out[8]: '0.15.0'
I am not familiar with pandas as numpy , but I am puzzled by why ix[:,:1] gives me a 2-column result. In numpy such an index gives only 1 column.
If I assign one column dtype does not change
In [47]: df.ix[:,[0]]=A[:,0] In [48]: df.dtypes Out[48]: 0 float32 1 float32 2 object
The same actions without mixed data types do not change dtypes
In [100]: df1 = pd.DataFrame([[1, 2, 1.23], [3, 4, 3.32]], dtype=np.float32) In [101]: A1=df1.ix[:,:1].values In [102]: df1.ix[:,:1]=A1 In [103]: df1.dtypes Out[103]: 0 float32 1 float32 2 float32 dtype: object
The key should be that with mixed values, the dataframe is in one way or another an array of dtype=object , whether true for its internal data store or just its numpy interface.
In [104]: df1.as_matrix() Out[104]: array([[ 1. , 2. , 1.23000002], [ 3. , 4. , 3.31999993]], dtype=float32) In [105]: df.as_matrix() Out[105]: array([[1.0, 2.0, 'a'], [3.0, 4.0, 'b']], dtype=object)