pydata/pandas — pull request #3110 by jreback (2013-03-20 23:30:00+00:00)
Title: BUG: fixed issues where passing an axis of 'index' would fail (as its ex...

BUG: some operations were expecting an axis number, this fix allows passing the regular axis name as well, e.g. ``df.sum(axis='columns')`` will now work

```
In [3]: df = pd.DataFrame(np.random.rand(5,2),columns=['A','B'])

In [4]: df.sum(axis=1)
Out[4]:
0 1.150325
1 0.789142
2 0.581486
3 0.864212
4 0.731511

In [5]: df.sum(axis='columns')
---------------------------------------------------------------------------

Exception: Must have 0<= axis <= 1

```

ENH:

- added ability to use the index name as the name of the axis
- added set_axis_alias/clear_axis_alias to set for an object type
(e.g. DataFrame/Panel), aliases at run-time
FYI: Panel already allows ``minor`` to substitue for ``minor_axis`` and
``major`` for ``major_axis``

**NOTE**
*This does not actually rename anything, just allows aliasing*

closes GH #3109

Using the local index names
```
In [183]: df = DataFrame(randn(3,2),columns=['c1','c2'],
index=['i1','i2','i3'])

In [184]: df.index.name = 'myaxis1'

In [185]: df.columns.name = 'myaxis2'

In [186]: df.sum(axis='myaxis1')
Out[186]:
myaxis2
c1 -0.168212
c2 0.166038
dtype: float64

In [187]: df.xs('c1', axis='myaxis2')
Out[187]:
myaxis1
i1 0.758071
i2 -0.548502
i3 -0.377780
Name: c1, dtype: float64
```

Globally set and clear for all frames
```
In [188]: DataFrame.set_axis_alias('columns', 'myaxis2')

In [189]: df2 = DataFrame(randn(3,2),columns=['c1','c2'],
index=['i1','i2','i3'])

In [190]: df2.sum(axis='myaxis2')
Out[190]:
i1 -0.613869
i2 -1.380343
i3 -1.502508
dtype: float64
```