Skip to content

ENH: add to_series() method to Index and subclasses GH3275 #3280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from Apr 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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 @@ -277,6 +279,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