pydata/pandas — pull request #4515 by jreback (2013-08-08 18:52:15+00:00)
Title: ENH:  GH2578, allow ix and friends to partially set when the key is not contained in the object

closes #2578

Note: Trying to set a value that does not exist (whether via ``[]/loc/iloc``) on a ``Series`` will
raise a ``KeyError/IndexError``; I left this alone, but I think this is pretty inconsistent with the ops below

```
In [6]: s = Series([1,2,3])

In [7]: s[4] = 5
In [8]: s.loc[4] = 5
```

This is now allowed: (previously would ``KeyError``), you first have to create the column ``C``, then set it

```
In [1]: df_orig = DataFrame(np.arange(6).reshape(3,2),columns=['A','B'])

In [2]: df = df_orig.copy()

In [3]: df
Out[3]:
A B
0 0 1
1 2 3
2 4 5

In [4]: df.ix[:,'C'] = df.ix[:,'A']

In [5]: df
Out[5]:
A B C
0 0 1 0
1 2 3 2
2 4 5 4
```

This would previously raise an ``IndexError``
```
In [3]: df = df_orig.copy()

In [4]: df.loc[3] = 5

In [5]: df
Out[5]:
A B
0 0 1
1 2 3
2 4 5
3 5 5
```

and on Panel:

```
In [6]: p_orig = Panel(np.arange(16).reshape(2,4,2),
items=['Item1','Item2'],
major_axis=pd.date_range('2001/1/12',periods=4),
minor_axis=['A','B'],dtype='float64')

In [7]: p_orig
Out[7]:

Dimensions: 2 (items) x 4 (major_axis) x 2 (minor_axis)
Items axis: Item1 to Item2
Major_axis axis: 2001-01-12 00:00:00 to 2001-01-15 00:00:00
Minor_axis axis: A to B

In [9]: p = p_orig.copy()

In [10]: p.loc[:,:,'C'] = Series([30,32],index=p_orig.items)

In [11]: p
Out[11]:

Dimensions: 2 (items) x 4 (major_axis) x 3 (minor_axis)
Items axis: Item1 to Item2
Major_axis axis: 2001-01-12 00:00:00 to 2001-01-15 00:00:00
Minor_axis axis: A to C

In [13]: p.loc[:,:,'C']
Out[13]:
Item1 Item2
2001-01-12 30 32
2001-01-13 30 32
2001-01-14 30 32
2001-01-15 30 32
```