Skip to content

Commit

Permalink
Merge pull request #3280 from y-p/GH3275
Browse files Browse the repository at this point in the history
ENH: add to_series() method to Index and subclasses GH3275
  • Loading branch information
y-p committed Apr 9, 2013
2 parents 1569838 + 004a25b commit c8728e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pandas 0.11.0
- Added support for expression evaluation using the ``numexpr`` library
- Added ``convert=boolean`` to ``take`` routines to translate negative
indices to positive, defaults to True
- Added to_series() method to indices, to facilitate the creation of indexeres
(GH3275_)

**Improvements to existing features**

Expand Down Expand Up @@ -292,6 +294,7 @@ pandas 0.11.0
.. _GH1893: https://github.com/pydata/pandas/issues/1893
.. _GH1978: https://github.com/pydata/pandas/issues/1978
.. _GH2758: https://github.com/pydata/pandas/issues/2758
.. _GH3275: https://github.com/pydata/pandas/issues/3275
.. _GH2121: https://github.com/pydata/pandas/issues/2121
.. _GH3247: https://github.com/pydata/pandas/issues/3247
.. _GH2809: https://github.com/pydata/pandas/issues/2809
Expand Down
4 changes: 4 additions & 0 deletions doc/source/v0.11.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ Astype conversion on ``datetime64[ns]`` to ``object``, implicity converts ``NaT`
API changes
~~~~~~~~~~~

- Added to_series() method to indicies, to facilitate the creation of indexers
(GH3275_)

- In ``HDFStore``, added the method ``select_column`` to select a single column from a table as a Series.

- In ``HDFStore``, deprecated the ``unique`` method, can be replicated by ``select_column(key,column).unique()``
Expand Down Expand Up @@ -343,6 +346,7 @@ on GitHub for a complete list.
.. _GH2807: https://github.com/pydata/pandas/issues/2807
.. _GH2918: https://github.com/pydata/pandas/issues/2918
.. _GH2758: https://github.com/pydata/pandas/issues/2758
.. _GH3275: https://github.com/pydata/pandas/issues/3275
.. _GH2979: https://github.com/pydata/pandas/issues/2979
.. _GH3011: https://github.com/pydata/pandas/issues/3011
.. _GH3076: https://github.com/pydata/pandas/issues/3076
Expand Down
8 changes: 8 additions & 0 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ def __repr__(self):
"""
return str(self)

def to_series(self):
"""
return a series with both index and values equal to the index keys
useful with map for returning an indexer based on an index
"""
import pandas as pd
return pd.Series(self.values,index=self,name=self.name)

def astype(self, dtype):
return Index(self.values.astype(dtype), name=self.name,
dtype=dtype)
Expand Down

0 comments on commit c8728e2

Please sign in to comment.