pydata/pandas — pull request #3219 by jreback (2013-03-29 17:47:58+00:00)
Title: BUG: GH3216 Upcast when needed to DataFrame when setitem with indexer

closes #3216

BUG: GH3216 Upcast when needed to DataFrame when setitem with indexer

The following would raise previously

```
In [8]: df = pd.DataFrame([{"a": 1}, {"a": 3, "b": 2}])
In [9]: df['c'] = np.nan
In [10]: df.ix[0,'c'] = 'foo'

In [11]: df
Out[11]:
a b c
0 1 NaN foo
1 3 2 NaN

In [12]: df.dtypes
Out[12]:
a int64
b float64
c object
dtype: object
```

ENH: On a mixed DataFrame, allow setting with indexers with
ndarray/DataFrame on rhs (this was disallowed in the code previously)

```
In [8]: df = DataFrame([[1,2,'foo'],[3,4,'bar']],columns=['A','B','C'])
In [9]: df2 = df.copy()
In [10]: df2.ix[:,['A','B']] = df.ix[:,['A','B']]+0.5
In [11]: df2
Out[11]:
A B C
0 1.5 2.5 foo
1 3.5 4.5 bar

In [12]: df2.dtypes
Out[12]:
A float64
B float64
C object
dtype: object

In [13]: df.dtypes
Out[13]:
A int64
B int64
C object
dtype: object
```